Add files via upload
This commit is contained in:
parent
8a7b85e562
commit
745591b7e7
5 changed files with 375 additions and 191 deletions
6
adblock.ts
Normal file
6
adblock.ts
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
const fetchr = require("cross-fetch")
|
||||||
|
const { ElectronBlocker, fullLists, Requests } = require('@cliqz/adblocker-electron')
|
||||||
|
|
||||||
|
let mainWindow: BrowserWindow | null = null;
|
||||||
|
let blocker = await ElectronBlocker.fromPrebuiltAdsAndTracking(fetchr);
|
||||||
|
blocker.enableBlockingInSession(mainWindow.webContents.defaultSession);
|
|
@ -9,7 +9,9 @@ function go() {
|
||||||
})
|
})
|
||||||
document.getElementById("txtUrl").value = ""
|
document.getElementById("txtUrl").value = ""
|
||||||
for (let i = 0; i < extensions.length; i++) {
|
for (let i = 0; i < extensions.length; i++) {
|
||||||
fetch(extensions[i]).then( r => r.text() ).then( t => browserFrame.executeJavaScript(t))
|
fetch(extensions[i]).then( r => r.text() ).then( t => browserFrame.executeJavaScript(t)).catch(() => {
|
||||||
|
console.log("Error loading extensions! (Did you provide any?)")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function back() {
|
function back() {
|
||||||
|
|
9
main.js
9
main.js
|
@ -1,6 +1,9 @@
|
||||||
// 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} = require('electron')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
const fetchr = require("cross-fetch")
|
||||||
|
const { ElectronBlocker, fullLists, Requests } = require('@cliqz/adblocker-electron')
|
||||||
|
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
|
@ -13,6 +16,12 @@ function createWindow () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ElectronBlocker.fromPrebuiltAdsAndTracking(fetchr).then((blocker) => {
|
||||||
|
blocker.enableBlockingInSession(mainWindow.webContents.defaultSession).catch(() => {
|
||||||
|
console.log("Blocker reported an error while init.")
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
mainWindow.loadFile('index.html')
|
mainWindow.loadFile('index.html')
|
||||||
|
|
||||||
|
|
544
package-lock.json
generated
544
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -27,6 +27,9 @@
|
||||||
"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",
|
||||||
"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