Adblocker: add option to disable default lists

This commit is contained in:
TC
2020-12-08 21:40:03 +01:00
parent 467171a17e
commit 22c7f70c93
3 changed files with 10 additions and 9 deletions

View File

@ -3,5 +3,6 @@ module.exports = (win, options) =>
loadAdBlockerEngine(
win.webContents.session,
options.cache,
options.additionalBlockLists
options.additionalBlockLists,
options.disableDefaultLists
);

View File

@ -11,7 +11,8 @@ const SOURCES = [
const loadAdBlockerEngine = (
session = undefined,
cache = true,
additionalBlockLists = []
additionalBlockLists = [],
disableDefaultLists = false
) => {
// Only use cache if no additional blocklists are passed
const cachingOptions =
@ -22,13 +23,12 @@ const loadAdBlockerEngine = (
write: promises.writeFile,
}
: undefined;
const lists = [
...(disableDefaultLists ? [] : SOURCES),
...additionalBlockLists,
];
ElectronBlocker.fromLists(
fetch,
[...SOURCES, ...additionalBlockLists],
{},
cachingOptions
)
ElectronBlocker.fromLists(fetch, lists, {}, cachingOptions)
.then((blocker) => {
if (session) {
blocker.enableBlockingInSession(session);