This commit is contained in:
JellyBrick
2023-10-04 22:53:25 +09:00
parent 78d8160823
commit 50117ea51b
2 changed files with 8 additions and 5 deletions

View File

@ -74,7 +74,7 @@ const defaultConfig = {
cache: true, cache: true,
blocker: 'With blocklists', blocker: 'With blocklists',
additionalBlockLists: [], // Additional list of filters, e.g "https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/filters.txt" additionalBlockLists: [], // Additional list of filters, e.g "https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/filters.txt"
disableDefaultLists: [], disableDefaultLists: false,
}, },
'album-color-theme': {}, 'album-color-theme': {},
'audio-compressor': {}, 'audio-compressor': {},

View File

@ -21,14 +21,14 @@ export const loadAdBlockerEngine = (
session: Electron.Session | undefined = undefined, session: Electron.Session | undefined = undefined,
cache = true, cache = true,
additionalBlockLists = [], additionalBlockLists = [],
disableDefaultLists: boolean | string[] = false, disableDefaultLists: boolean | unknown[] = false,
) => { ) => {
// Only use cache if no additional blocklists are passed // Only use cache if no additional blocklists are passed
let cacheDirectory: string; let cacheDirectory: string;
if (app.isPackaged) { if (app.isPackaged) {
cacheDirectory = path.join(app.getPath('userData'), 'cache'); cacheDirectory = path.join(app.getPath('userData'), 'adblock_cache');
} else { } else {
cacheDirectory = path.resolve(__dirname, 'cache'); cacheDirectory = path.resolve(__dirname, 'adblock_cache');
} }
if (!fs.existsSync(cacheDirectory)) { if (!fs.existsSync(cacheDirectory)) {
fs.mkdirSync(cacheDirectory); fs.mkdirSync(cacheDirectory);
@ -42,7 +42,10 @@ export const loadAdBlockerEngine = (
} }
: undefined; : undefined;
const lists = [ const lists = [
...(disableDefaultLists ? [] : SOURCES), ...(
(disableDefaultLists && !Array.isArray(disableDefaultLists)) ||
(Array.isArray(disableDefaultLists) && disableDefaultLists.length > 0) ? [] : SOURCES
),
...additionalBlockLists, ...additionalBlockLists,
]; ];