blob: 34a51514b3c0ebbdc841217bf0cbee409b5e61c0 (
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
37
38
39
40
41
42
43
|
import './ci-link.css';
import select from 'select-dom';
import onetime from 'onetime';
import * as pageDetect from 'github-url-detection';
import features from '.';
import fetchDom from '../helpers/fetch-dom';
import {getRepoURL} from '../github-helpers';
// Look for the CI icon in the latest 2 days of commits #2990
const getIcon = onetime(fetchDom.bind(null,
`/${getRepoURL()}/commits`, [
'.commit-group:nth-of-type(-n+2) .commit-build-statuses', // Pre "Repository refresh" layout
'.TimelineItem--condensed:nth-of-type(-n+2) .commit-build-statuses'
].join()
));
async function init(): Promise<false | void> {
const icon = await getIcon() as HTMLElement | undefined;
if (!icon) {
return false;
}
icon.classList.add('rgh-ci-link');
if (onetime.callCount(getIcon) > 1) {
icon.style.animation = 'none';
}
// Append to title (aware of forks and private repos)
select('[itemprop="name"]')!.parentElement!.append(icon);
}
void features.add({
id: __filebasename,
description: 'Add build status and link to CI after the repo’s title.',
screenshot: 'https://user-images.githubusercontent.com/1402241/32562120-d65166e4-c4e8-11e7-90fb-cbaf36e2709f.png'
}, {
include: [
pageDetect.isRepo
],
waitForDomReady: false,
init
});
|