Skip to content

Commit

Permalink
Adblocker: add option to disable default lists
Browse files Browse the repository at this point in the history
  • Loading branch information
th-ch committed Dec 8, 2020
1 parent 467171a commit 22c7f70
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "youtube-music",
"productName": "YouTube Music",
"version": "1.7.2",
"version": "1.7.3",
"description": "YouTube Music Desktop App - including custom plugins",
"license": "MIT",
"repository": "th-ch/youtube-music",
Expand Down
3 changes: 2 additions & 1 deletion plugins/adblocker/back.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ module.exports = (win, options) =>
loadAdBlockerEngine(
win.webContents.session,
options.cache,
options.additionalBlockLists
options.additionalBlockLists,
options.disableDefaultLists
);
14 changes: 7 additions & 7 deletions plugins/adblocker/blocker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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);
Expand Down

0 comments on commit 22c7f70

Please sign in to comment.