-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscriptLoader.js
58 lines (51 loc) · 2 KB
/
scriptLoader.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
let initialURL = window.location.href;
if (
initialURL === "https://www.youtube.com/feed/subscriptions" ||
initialURL === "https://www.youtube.com/feed/explore" ||
initialURL === "https://www.youtube.com/gaming" ||
initialURL.match(/https\:\/\/www\.youtube\.com\/c\/.*\/videos/g) ||
initialURL.match(/https\:\/\/www\.youtube\.com\/user\/.*\/videos/g) ||
initialURL.includes("https://www.youtube.com/feed/trending")
) {
if (document.getElementById('gamefinderExtensionScript')) {
document.getElementById('gamefinderExtensionScript').remove();
};
let script = document.createElement('script');
script.id = 'gamefinderExtensionScript';
script.src = chrome.runtime.getURL("subscriptions.js");
(document.head || document.documentElement).appendChild(script);
script.onload = function() {
this.remove();
};
} else if (
initialURL === "https://www.youtube.com/" ||
initialURL.includes("https://www.youtube.com/channel/")) {
if (document.getElementById('gamefinderExtensionScript')) {
document.getElementById('gamefinderExtensionScript').remove();
};
let script = document.createElement('script');
script.id = 'gamefinderExtensionScript';
script.src = chrome.runtime.getURL("home.js");
(document.head || document.documentElement).appendChild(script);
script.onload = function() {
this.remove();
};
} else if (initialURL.includes("https://www.youtube.com/watch?v=")) {
if (document.getElementById('gamefinderExtensionScript')) {
document.getElementById('gamefinderExtensionScript').remove();
};
let script = document.createElement('script');
script.id = 'gamefinderExtensionScript';
script.src = chrome.runtime.getURL("recommended.js");
(document.head || document.documentElement).appendChild(script);
script.onload = function() {
this.remove();
};
}
const URLChangeChecker = () => {
if (initialURL !== window.location.href) {
initialURL = window.location.href;
window.location.reload();
}
}
const checkURLInterval = setInterval(URLChangeChecker, 300);