Compare commits

...

1 Commits

Author SHA1 Message Date
TC
22c7f70c93 Adblocker: add option to disable default lists 2020-12-08 21:40:03 +01:00
3 changed files with 10 additions and 9 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "youtube-music", "name": "youtube-music",
"productName": "YouTube Music", "productName": "YouTube Music",
"version": "1.7.2", "version": "1.7.3",
"description": "YouTube Music Desktop App - including custom plugins", "description": "YouTube Music Desktop App - including custom plugins",
"license": "MIT", "license": "MIT",
"repository": "th-ch/youtube-music", "repository": "th-ch/youtube-music",

View File

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

View File

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