-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
35 lines (28 loc) · 823 Bytes
/
script.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
let id = 0;
let __tabs = [];
let pattern = [];
chrome.storage.local.get(["pattern"], function (items) {
pattern = items['pattern'];
chrome.webRequest.onBeforeRequest.addListener(
redirect,
{urls: pattern},
["blocking"]
);
});
function redirect(requestDetails) {
console.log("%c " + requestDetails.url + " redirected", 'color: #00ff00');
chrome.tabs.query({active: true}, function (tabs) {
id = tabs[0].id;
__tabs.push(id.toString())
let count = 0;
for (let i = 0; i < __tabs.length; i++) {
if (__tabs[i].toString() === id.toString()) {
count++;
}
}
chrome.browserAction.setBadgeText({tabId: id, text: "" + count});
});
return {
redirectUrl: "https://0.0.0.0/"
};
}