mirror of
https://github.com/QuiteAFancyEmerald/Holy-Unblocker.git
synced 2025-05-13 03:50:02 -04:00
Updated a few more things
This commit is contained in:
parent
c827e9f7e1
commit
73cdcb3186
47 changed files with 35805 additions and 1102 deletions
45
lib/browser/iframe.js
Normal file
45
lib/browser/iframe.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
const { overrideAccessors } = require("./utils");
|
||||
|
||||
function createIframeRewriter(ctx) {
|
||||
if (ctx.serviceWorker) return () => null;
|
||||
const {
|
||||
HTMLIFrameElement
|
||||
} = ctx.window;
|
||||
function rewriteContentDocument() {
|
||||
overrideAccessors(HTMLIFrameElement.prototype, 'contentDocument', {
|
||||
getter: (target, that) => {
|
||||
const doc = target.call(that);
|
||||
try {
|
||||
if (!doc.defaultView.$corrosion) initCorrosion(doc.defaultView);
|
||||
return doc;
|
||||
} catch(e) {
|
||||
return doc;
|
||||
};
|
||||
},
|
||||
});
|
||||
};
|
||||
function rewriteContentWindow() {
|
||||
overrideAccessors(HTMLIFrameElement.prototype, 'contentWindow', {
|
||||
getter: (target, that) => {
|
||||
const win = target.call(that);
|
||||
try {
|
||||
if (!win.$corrosion) initCorrosion(win);
|
||||
return win;
|
||||
} catch(e) {
|
||||
return win;
|
||||
};
|
||||
},
|
||||
});
|
||||
};
|
||||
function initCorrosion(win) {
|
||||
win.$corrosion = new ctx.constructor({ ...ctx.config, window: win, });
|
||||
win.$corrosion.init();
|
||||
win.$corrosion.meta = ctx.meta;
|
||||
};
|
||||
return function rewriteIframe() {
|
||||
rewriteContentWindow();
|
||||
rewriteContentDocument();
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = createIframeRewriter;
|
Loading…
Add table
Add a link
Reference in a new issue