summaryrefslogtreecommitdiff
path: root/source/features/dim-bots.tsx
blob: a1d753c838d7409320562cfb50fc80e7b2d99feb (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
import './dim-bots.css';
import select from 'select-dom';
import * as pageDetect from 'github-url-detection';

import features from '.';

// eslint-disable-next-line import/prefer-default-export
export const botSelectors = [
	/* Commits */
	'.commit-author[href$="%5Bbot%5D"]:first-child',
	'.commit-author[href$="renovate-bot"]:first-child',
	'.commit-author[href$="scala-steward"]:first-child',

	/* Issues/PRs */
	'.opened-by [href*="author%3Aapp%2F"]'
];

function init(): void {
	for (const bot of select.all(botSelectors)) {
		bot.closest('.commit, .Box-row')!.classList.add('rgh-dim-bot');
	}
}

void features.add({
	id: __filebasename,
	description: 'Dims commits and PRs by bots to reduce noise.',
	screenshot: 'https://user-images.githubusercontent.com/1402241/65263190-44c52b00-db36-11e9-9b33-d275d3c8479d.gif'
}, {
	include: [
		pageDetect.isCommitList,
		pageDetect.isConversationList
	],
	init
});