summaryrefslogtreecommitdiff
path: root/source/features/link-to-compare-diff.tsx
blob: da5df859ef1c51fea761de4382374b2967a1db0b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import './link-to-compare-diff.css';
import React from 'dom-chef';
import {elementExists} from 'select-dom';
import * as pageDetect from 'github-url-detection';

import features from '../feature-manager.js';
import {wrapAll} from '../helpers/dom-utils.js';
import selectHas from '../helpers/select-has.js';

function init(): void {
	const changedFilesSummary = selectHas('.Box li:has(.octicon-file-diff)')!;
	wrapAll(
		[...changedFilesSummary.children],
		<a className="no-underline rgh-link-to-compare-diff" href="#files_bucket"/>,
	);
}

void features.add(import.meta.url, {
	include: [
		pageDetect.isCompare,
	],
	exclude: [
		() => elementExists('.tabnav'), // The commit list and compare diff are in two separate tabs
	],
	deduplicate: 'has-rgh-inner',
	awaitDomReady: true, // DOM-based filter
	init,
});