Add files via upload

This commit is contained in:
NodeMixaholic 2023-03-03 08:30:52 -06:00 committed by GitHub
parent af141833ad
commit 3c1bfc75ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 13 deletions

54
main.js
View file

@ -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

View file

@ -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"