-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (38 loc) · 890 Bytes
/
index.js
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
let target;
switch (location.host) {
case "github.com":
case "x.com":
case "mobile.x.com": {
/**
* Get root domain
* @see https://stackoverflow.com/a/61381607/270302
*/
const rootDomain = location.host.split(".").slice(-2).join(".");
target = rootDomain;
break;
}
default: {
const domain = location.host.replace("www.", "");
switch (domain) {
case "britishmuseum.org":
case "holy-bhagavad-gita.org":
case "google.com":
case "ggpht.com":
case "guidestar.org":
case "npmjs.com":
case "reddit.com":
case "youtube.com":
// biome-ignore lint/suspicious/noFallthroughSwitchClause: intentional
target = domain;
default: {
if (/(ggpht|googleusercontent).com$/.test(domain)) {
target = "ggpht.com";
}
}
}
}
}
if (target) {
console.log("loading script", new Date(), target);
await import(`./${target}/index.js`);
}