Update main.js
This commit is contained in:
parent
6b99a1ce40
commit
b3c6cada02
1 changed files with 15 additions and 4 deletions
19
main.js
19
main.js
|
@ -59,16 +59,27 @@ const toBlock = [
|
||||||
"*://*.trafficleader.com/*",
|
"*://*.trafficleader.com/*",
|
||||||
"*://*.trafficrouter.io/*",
|
"*://*.trafficrouter.io/*",
|
||||||
"*://*.monerominer.rocks/*",
|
"*://*.monerominer.rocks/*",
|
||||||
"*://*.googlevideo.com/*",
|
|
||||||
"*://*.2mdn.net/*",
|
"*://*.2mdn.net/*",
|
||||||
"*.exe",
|
"*.exe",
|
||||||
"*.vbs"
|
"*.vbs",
|
||||||
|
]
|
||||||
|
|
||||||
|
const regexPatterns = [
|
||||||
|
"/api\/v\d\/science$/g",
|
||||||
|
"r[0-9]+---sn-.*\.googlevideo\.com$/g"
|
||||||
]
|
]
|
||||||
|
|
||||||
function containsAD(url) {
|
function containsAD(url) {
|
||||||
var i;
|
var i;
|
||||||
for (i = 0; i < toBlock.length; i++) {
|
for (i = 0; i < toBlock.length; i++) {
|
||||||
regex = toBlock[i].replace(/\*/g, "[^ ]*");
|
let regex = toBlock[i].replace(/\*/g, "[^ ]*");
|
||||||
|
if (url.match(regex)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < regexPatterns.length; i++) {
|
||||||
|
let regex = regexPatterns[i]
|
||||||
if (url.match(regex)) {
|
if (url.match(regex)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +89,7 @@ const toBlock = [
|
||||||
}
|
}
|
||||||
|
|
||||||
session.defaultSession.webRequest.onBeforeRequest((details, callback) => {
|
session.defaultSession.webRequest.onBeforeRequest((details, callback) => {
|
||||||
if(/api\/v\d\/science$/g.test(details.url) || containsAD(details.url)) {
|
if (containsAD(details.url)) {
|
||||||
return callback({cancel: true})
|
return callback({cancel: true})
|
||||||
}
|
}
|
||||||
return callback({})
|
return callback({})
|
||||||
|
|
Loading…
Reference in a new issue