Add files via upload
This commit is contained in:
parent
af141833ad
commit
3c1bfc75ab
3 changed files with 49 additions and 13 deletions
54
main.js
54
main.js
|
@ -1,8 +1,7 @@
|
||||||
// Modules to control application life and create native browser window
|
// Modules to control application life and create native browser window
|
||||||
const {app, BrowserWindow} = require('electron')
|
const {app, BrowserWindow, session} = require('electron')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const fetchr = require("cross-fetch")
|
const fetch = require("cross-fetch")
|
||||||
const { ElectronBlocker, fullLists, Requests } = require('@cliqz/adblocker-electron')
|
|
||||||
|
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
|
@ -16,17 +15,56 @@ function createWindow () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ElectronBlocker.fromPrebuiltAdsAndTracking(fetchr).then((blocker) => {
|
|
||||||
blocker.enableBlockingInSession(mainWindow.webContents.defaultSession).catch(() => {
|
const toBlock = [
|
||||||
console.log("Blocker reported an error while init.")
|
"*://*.doubleclick.net/*",
|
||||||
|
"*://partner.googleadservices.com/*",
|
||||||
|
"*://*.googlesyndication.com/*",
|
||||||
|
"*://*.google-analytics.com/*",
|
||||||
|
"*://creative.ak.fbcdn.net/*",
|
||||||
|
"*://*.adbrite.com/*",
|
||||||
|
"*://*.exponential.com/*",
|
||||||
|
"*://*.quantserve.com/*",
|
||||||
|
"*://*.scorecardresearch.com/*",
|
||||||
|
"*://*.zedo.com/*",
|
||||||
|
"*://*.a-ads.com/*",
|
||||||
|
"*://*.777partner.com/*",
|
||||||
|
"*://*.77tracking.com/*",
|
||||||
|
"*://*.abc-ads.com/*",
|
||||||
|
"*://*.aaxads.com/*",
|
||||||
|
"*://*.adizio.com/*",
|
||||||
|
"*://*.adjix.com/*",
|
||||||
|
"*://*.adjug.com/*",
|
||||||
|
"*://*.adjuggler.com/*",
|
||||||
|
"*://*.trafficjunky.net/*",
|
||||||
|
"*://*.trafficleader.com/*",
|
||||||
|
"*://*.trafficrouter.io/*"
|
||||||
|
]
|
||||||
|
|
||||||
|
function containsAD(url) {
|
||||||
|
var i;
|
||||||
|
for (i = 0; i < toBlock.length; i++) {
|
||||||
|
regex = toBlock[i].replace(/\*/g, "[^ ]*");
|
||||||
|
if (url.match(regex)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
session.defaultSession.webRequest.onBeforeRequest((details, callback) => {
|
||||||
|
if(/api\/v\d\/science$/g.test(details.url) || containsAD(details.url)) {
|
||||||
|
return callback({cancel: true})
|
||||||
|
}
|
||||||
|
return callback({})
|
||||||
})
|
})
|
||||||
});
|
|
||||||
|
|
||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
mainWindow.loadFile('index.html')
|
mainWindow.loadFile('index.html')
|
||||||
|
|
||||||
// Open the DevTools.
|
// Open the DevTools.
|
||||||
// mainWindow.webContents.openDevTools()
|
mainWindow.webContents.openDevTools()
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
|
|
|
@ -27,8 +27,6 @@
|
||||||
"electron": "^23.1.0"
|
"electron": "^23.1.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cliqz/adblocker": "^1.26.2",
|
|
||||||
"@cliqz/adblocker-electron": "^1.26.2",
|
|
||||||
"cross-fetch": "^3.1.5",
|
"cross-fetch": "^3.1.5",
|
||||||
"electron-squirrel-startup": "^1.0.0",
|
"electron-squirrel-startup": "^1.0.0",
|
||||||
"electron-tabs": "^1.0.1"
|
"electron-tabs": "^1.0.1"
|
||||||
|
|
Loading…
Reference in a new issue