Add files via upload
This commit is contained in:
parent
af141833ad
commit
3c1bfc75ab
3 changed files with 49 additions and 13 deletions
|
@ -33,4 +33,4 @@ function clickPress(keyEvent) {
|
|||
if (keyEvent.keyCode == 13) {
|
||||
go()
|
||||
}
|
||||
}
|
||||
}
|
58
main.js
58
main.js
|
@ -1,8 +1,7 @@
|
|||
// 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 fetchr = require("cross-fetch")
|
||||
const { ElectronBlocker, fullLists, Requests } = require('@cliqz/adblocker-electron')
|
||||
const fetch = require("cross-fetch")
|
||||
|
||||
|
||||
function createWindow () {
|
||||
|
@ -16,17 +15,56 @@ function createWindow () {
|
|||
}
|
||||
})
|
||||
|
||||
ElectronBlocker.fromPrebuiltAdsAndTracking(fetchr).then((blocker) => {
|
||||
blocker.enableBlockingInSession(mainWindow.webContents.defaultSession).catch(() => {
|
||||
console.log("Blocker reported an error while init.")
|
||||
})
|
||||
});
|
||||
|
||||
const toBlock = [
|
||||
"*://*.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.
|
||||
mainWindow.loadFile('index.html')
|
||||
|
||||
// Open the DevTools.
|
||||
// mainWindow.webContents.openDevTools()
|
||||
mainWindow.webContents.openDevTools()
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
|
@ -50,4 +88,4 @@ app.on('window-all-closed', function () {
|
|||
})
|
||||
|
||||
// In this file you can include the rest of your app's specific main process
|
||||
// code. You can also put them in separate files and require them here.
|
||||
// code. You can also put them in separate files and require them here.
|
|
@ -27,8 +27,6 @@
|
|||
"electron": "^23.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@cliqz/adblocker": "^1.26.2",
|
||||
"@cliqz/adblocker-electron": "^1.26.2",
|
||||
"cross-fetch": "^3.1.5",
|
||||
"electron-squirrel-startup": "^1.0.0",
|
||||
"electron-tabs": "^1.0.1"
|
||||
|
|
Loading…
Reference in a new issue