Skip to content

Commit

Permalink
fix: fix #29
Browse files Browse the repository at this point in the history
  • Loading branch information
JellyBrick committed Oct 4, 2023
1 parent 78d8160 commit 50117ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion config/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const defaultConfig = {
cache: true,
blocker: 'With blocklists',
additionalBlockLists: [], // Additional list of filters, e.g "https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/filters.txt"
disableDefaultLists: [],
disableDefaultLists: false,
},
'album-color-theme': {},
'audio-compressor': {},
Expand Down
11 changes: 7 additions & 4 deletions plugins/adblocker/blocker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ export const loadAdBlockerEngine = (
session: Electron.Session | undefined = undefined,
cache = true,
additionalBlockLists = [],
disableDefaultLists: boolean | string[] = false,
disableDefaultLists: boolean | unknown[] = false,
) => {
// Only use cache if no additional blocklists are passed
let cacheDirectory: string;
if (app.isPackaged) {
cacheDirectory = path.join(app.getPath('userData'), 'cache');
cacheDirectory = path.join(app.getPath('userData'), 'adblock_cache');
} else {
cacheDirectory = path.resolve(__dirname, 'cache');
cacheDirectory = path.resolve(__dirname, 'adblock_cache');
}
if (!fs.existsSync(cacheDirectory)) {
fs.mkdirSync(cacheDirectory);
Expand All @@ -42,7 +42,10 @@ export const loadAdBlockerEngine = (
}
: undefined;
const lists = [
...(disableDefaultLists ? [] : SOURCES),
...(
(disableDefaultLists && !Array.isArray(disableDefaultLists)) ||
(Array.isArray(disableDefaultLists) && disableDefaultLists.length > 0) ? [] : SOURCES
),
...additionalBlockLists,
];

Expand Down

0 comments on commit 50117ea

Please sign in to comment.