mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-12 19:01:47 +00:00
fix: use ghostry adblocker
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
import path from 'node:path';
|
||||
import fs, { promises } from 'node:fs';
|
||||
|
||||
import { ElectronBlocker } from '@cliqz/adblocker-electron';
|
||||
import { ElectronBlocker } from '@ghostery/adblocker-electron';
|
||||
import { app, net } from 'electron';
|
||||
|
||||
const SOURCES = [
|
||||
@ -55,6 +55,7 @@ export const loadAdBlockerEngine = async (
|
||||
(url: string) => net.fetch(url),
|
||||
lists,
|
||||
{
|
||||
enableCompression: true,
|
||||
// When generating the engine for caching, do not load network filters
|
||||
// So that enhancing the session works as expected
|
||||
// Allowing to define multiple webRequest listeners
|
||||
@ -66,7 +67,7 @@ export const loadAdBlockerEngine = async (
|
||||
blocker.enableBlockingInSession(session);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('Error loading adBlocker engine', error);
|
||||
console.error('Error loading adBlocker engine', error);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -8,7 +8,6 @@ import {
|
||||
unloadAdBlockerEngine,
|
||||
} from './blocker';
|
||||
|
||||
import injectCliqzPreload from './injectors/inject-cliqz-preload';
|
||||
import { inject, isInjected } from './injectors/inject';
|
||||
import { loadAdSpeedup } from './adSpeedup';
|
||||
|
||||
@ -134,18 +133,13 @@ export default createPlugin({
|
||||
async start({ getConfig }) {
|
||||
const config = await getConfig();
|
||||
|
||||
if (config.blocker === blockers.WithBlocklists) {
|
||||
// Preload adblocker to inject scripts/styles
|
||||
await injectCliqzPreload();
|
||||
} else if (config.blocker === blockers.InPlayer && !isInjected()) {
|
||||
if (config.blocker === blockers.InPlayer && !isInjected()) {
|
||||
inject(contextBridge);
|
||||
await webFrame.executeJavaScript(this.script);
|
||||
}
|
||||
},
|
||||
async onConfigChange(newConfig) {
|
||||
if (newConfig.blocker === blockers.WithBlocklists) {
|
||||
await injectCliqzPreload();
|
||||
} else if (newConfig.blocker === blockers.InPlayer && !isInjected()) {
|
||||
if (newConfig.blocker === blockers.InPlayer && !isInjected()) {
|
||||
inject(contextBridge);
|
||||
await webFrame.executeJavaScript(this.script);
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
export default async () => {
|
||||
await import('@cliqz/adblocker-electron-preload');
|
||||
await import('@ghostery/adblocker-electron-preload');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user