summaryrefslogtreecommitdiff
path: root/source/features/linkify-notification-repository-header.tsx
blob: fc6dc8c36f4ab5313d21905b2cf757c2393c2cdc (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
import React from 'dom-chef';
import * as pageDetect from 'github-url-detection';

import features from '../feature-manager.js';
import observe from '../helpers/selector-observer.js';

function linkify(header: HTMLElement): void {
	header.append(
		<a className="color-fg-inherit" href={'/' + header.textContent!.trim()}>
			{header.firstChild}
		</a>,
	);
}

function init(signal: AbortSignal): void {
	observe('.js-notifications-group h6', linkify, {signal});
}

void features.add(import.meta.url, {
	include: [
		pageDetect.isNotifications,
	],
	exclude: [
		pageDetect.isBlank, // Empty notification list
	],
	init,
});