-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
github.ts
36 lines (31 loc) · 1.14 KB
/
github.ts
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
import {
getGithubUsername,
isGithubProfilePage,
isGithubPullRequestPage,
} from "../utils/urlMatchers";
import { isOpenSaucedUser } from "../utils/fetchOpenSaucedApiData";
import injectViewOnOpenSauced from "../utils/dom-utils/viewOnOpenSauced";
import injectInviteToOpenSauced from "../utils/dom-utils/inviteToOpenSauced";
import { prefersDarkMode } from "../utils/colorPreference";
import injectAddPRToHighlightsButton from "../utils/dom-utils/addPRToHighlights";
import domUpdateWatch from "../utils/dom-utils/domUpdateWatcher";
const processGithubPage = async () => {
if (prefersDarkMode(document.cookie)) {
document.documentElement.classList.add("dark");
}
if (isGithubPullRequestPage(window.location.href)) {
setTimeout(injectAddPRToHighlightsButton, 10);
} else if (isGithubProfilePage(window.location.href)) {
const username = getGithubUsername(window.location.href);
if (!username) {
return;
}
if (await isOpenSaucedUser(username)) {
injectViewOnOpenSauced(username);
} else {
injectInviteToOpenSauced(username);
}
}
domUpdateWatch(processGithubPage);
};
void processGithubPage();