-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
bypass-checks.tsx
40 lines (35 loc) · 1.44 KB
/
bypass-checks.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
34
35
36
37
38
39
40
import onetime from 'onetime';
import {observe} from 'selector-observer';
import * as pageDetect from 'github-url-detection';
import features from '.';
import * as api from '../github-helpers/api';
import {getRepoURL} from '../github-helpers';
async function bypass(detailsLink: HTMLAnchorElement): Promise<void> {
const runId = new URLSearchParams(detailsLink.search).get('check_run_id') ?? detailsLink.pathname.split('/').pop()!;
const directLink = await api.v3(`repos/${getRepoURL()}/check-runs/${runId}`);
detailsLink.href = directLink.details_url;
}
function init(): void {
// This selector excludes URLs that are already external
const thirdPartyApps = [
`a:not([href="/apps/github-actions"]) ~ div .status-actions[href^="${location.origin}"]:not(.rgh-bypass-link)`, // Hovercard status checks
'a:not([href="/apps/github-actions"]) ~ div .status-actions[href^="/"]:not(.rgh-bypass-link)'
].join();
observe(thirdPartyApps, {
constructor: HTMLAnchorElement,
add(thirdPartyApp) {
thirdPartyApp.classList.add('rgh-bypass-link');
void bypass(thirdPartyApp);
}
});
}
void features.add({
id: __filebasename,
description: 'Bypasses the "Checks" interstitial when clicking the "Details" links on a PR Checks added by third-party services like Travis.',
screenshot: 'https://user-images.githubusercontent.com/2103975/49071220-c6596e80-f22d-11e8-8a1e-bdcd62aa6ece.png'
}, {
include: [
pageDetect.isPRConversation
],
init: onetime(init)
});