mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-14 03:41:46 +00:00
@ -10,11 +10,11 @@ import {
|
|||||||
|
|
||||||
import injectCliqzPreload from './injectors/inject-cliqz-preload';
|
import injectCliqzPreload from './injectors/inject-cliqz-preload';
|
||||||
import { inject, isInjected } from './injectors/inject';
|
import { inject, isInjected } from './injectors/inject';
|
||||||
|
import { loadAdSpeedup } from './adSpeedup';
|
||||||
|
|
||||||
import { t } from '@/i18n';
|
import { t } from '@/i18n';
|
||||||
|
|
||||||
import type { BrowserWindow } from 'electron';
|
import type { BrowserWindow } from 'electron';
|
||||||
import { loadAdSpeedup } from './adSpeedup';
|
|
||||||
|
|
||||||
interface AdblockerConfig {
|
interface AdblockerConfig {
|
||||||
/**
|
/**
|
||||||
@ -74,7 +74,7 @@ export default createPlugin({
|
|||||||
];
|
];
|
||||||
},
|
},
|
||||||
renderer: {
|
renderer: {
|
||||||
async onPlayerApiReady(_, {getConfig}) {
|
async onPlayerApiReady(_, { getConfig }) {
|
||||||
const config = await getConfig();
|
const config = await getConfig();
|
||||||
if (config.blocker === blockers.AdSpeedup) {
|
if (config.blocker === blockers.AdSpeedup) {
|
||||||
await loadAdSpeedup();
|
await loadAdSpeedup();
|
||||||
@ -118,7 +118,18 @@ export default createPlugin({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
preload: {
|
preload: {
|
||||||
script: 'window.JSON.parse = window._proxyJsonParse; window._proxyJsonParse = undefined; window.Response.prototype.json = window._proxyResponseJson; window._proxyResponseJson = undefined; 0',
|
script: `const _prunerFn = window._pruner;
|
||||||
|
window._pruner = undefined;
|
||||||
|
JSON.parse = new Proxy(JSON.parse, {
|
||||||
|
apply() {
|
||||||
|
return _prunerFn(Reflect.apply(...arguments));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
Response.prototype.json = new Proxy(Response.prototype.json, {
|
||||||
|
apply() {
|
||||||
|
return Reflect.apply(...arguments).then((o) => _prunerFn(o));
|
||||||
|
},
|
||||||
|
}); 0`,
|
||||||
async start({ getConfig }) {
|
async start({ getConfig }) {
|
||||||
const config = await getConfig();
|
const config = await getConfig();
|
||||||
|
|
||||||
|
|||||||
@ -37,19 +37,9 @@ export const inject = (contextBridge) => {
|
|||||||
|
|
||||||
//
|
//
|
||||||
return o;
|
return o;
|
||||||
};
|
}
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld('_proxyJsonParse', new Proxy(JSON.parse, {
|
contextBridge.exposeInMainWorld('_pruner', pruner);
|
||||||
apply() {
|
|
||||||
return pruner(Reflect.apply(...arguments));
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld('_proxyResponseJson', new Proxy(Response.prototype.json, {
|
|
||||||
apply() {
|
|
||||||
return Reflect.apply(...arguments).then((o) => pruner(o));
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const chains = [
|
const chains = [
|
||||||
|
|||||||
Reference in New Issue
Block a user