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