-
Notifications
You must be signed in to change notification settings - Fork 2
/
background.js
43 lines (39 loc) · 1.34 KB
/
background.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
// check if browser is defined if it is not defined then define it as chrome because of firefox support
var isFirefox = true;
if (typeof browser === "undefined") {
var browser = chrome;
isFirefox = false;
}
if (isFirefox) {
const gamePattern = /https:\/\/.+roblox.com\/games\/\d+/;
async function handleUpdated(tabId, changeInfo, tabInfo) {
var pageUrl = tabInfo.url;
if (changeInfo.status !== 'complete' || !gamePattern.test(pageUrl)){ return; }
browser.scripting.insertCSS({
target: { tabId: tabId },
files: ["css/style.css"],
})
browser.scripting.executeScript({
target: { tabId: tabId },
files: ["js/jquery.js", "load.js"],
});
}
browser.tabs.onUpdated.addListener(handleUpdated, {
properties: [
"url",
"status"
]
});
} else {
browser.tabs.onUpdated.addListener(async (tabId, changeInfo, { url }) => {
if (changeInfo.status !== 'complete' || !/https:\/\/.+roblox.com\/games/g.test(url)) return;
await browser.scripting.insertCSS({
target: { tabId: tabId },
files: ["css/style.css"],
})
browser.scripting.executeScript({
target: { tabId: tabId },
files: ["js/jquery.js", "load.js"],
});
})
}