forked from refined-github/refined-github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
archive-forks-link.tsx
33 lines (27 loc) · 830 Bytes
/
archive-forks-link.tsx
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
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';
import {buildRepoURL} from '../github-helpers/index.js';
function addLinkToBanner(banner: HTMLElement): void {
if (banner.lastChild!.textContent.includes('repository has been archived')) {
banner.lastChild!.after(
' You can check out ',
<a href={buildRepoURL('forks')}>its forks</a>,
'.',
);
}
}
function init(signal: AbortSignal): void {
observe('#js-repo-pjax-container > .flash-warn', addLinkToBanner, {signal});
}
void features.add(import.meta.url, {
include: [
pageDetect.isRepo,
],
init,
});
/*
Test URLs:
https://github.com/probot/template/blob/master/CODE_OF_CONDUCT.md?rgh-link-date=2022-10-12T08%3A11%3A41Z
*/