summaryrefslogtreecommitdiff
path: root/source/features/rgh-dim-commits.tsx
blob: 7877bbd8f91292c3922737d440ce492ee5d89ffb (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
29
30
31
32
33
34
35
36
import * as pageDetect from 'github-url-detection';

import {isRefinedGitHubRepo} from '../github-helpers/index.js';
import features from '../feature-manager.js';
import observe from '../helpers/selector-observer.js';

// Source: https://github.com/fregante/release-with-changelog/blob/779fd5e658f82e5b11b1c0a352a6838d3bd8f67f/generate-release-notes.js#L6
const excludePreset = /^bump |^meta|^document|^lint|^refactor|readme|dependencies|^v?\d+\.\d+\.\d+/i;

function dim(commitTitle: HTMLElement): void {
	if (excludePreset.test(commitTitle.textContent!.trim())) {
		commitTitle.closest('.js-commits-list-item')!.style.opacity = '50%';
	}
}

function init(signal: AbortSignal): void {
	observe('.js-commits-list-item p:has(> .js-navigation-open)', dim, {signal});
}

void features.add(import.meta.url, {
	asLongAs: [
		isRefinedGitHubRepo,
	],
	include: [
		pageDetect.isCommitList,
	],
	init,
});

/*

Test URLs:

https://github.com/refined-github/refined-github/commits/98fb24e53704b436d68f254429885fb7bef09541/source/features/bypass-checks.tsx

*/