mirror of https://github.com/gorhill/uBlock.git
Prevent set-constant properties from being overtaken
Related feedback: - https://github.com/uBlockOrigin/uBlock-issues/issues/156#issuecomment-707095193 Additionally, while investigating the issue I removed code which is no longer needed since content scripts are now injected in `about:blank` frames since 1.29.0.
This commit is contained in:
parent
422e3f676f
commit
6e010ecc0f
|
@ -754,7 +754,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Object.defineProperty(owner, prop, {
|
Object.defineProperty(owner, prop, {
|
||||||
configurable: true,
|
configurable: false,
|
||||||
get() {
|
get() {
|
||||||
if ( prevGetter !== undefined ) {
|
if ( prevGetter !== undefined ) {
|
||||||
prevGetter();
|
prevGetter();
|
||||||
|
|
|
@ -94,64 +94,6 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
injectScriptlets(document);
|
injectScriptlets(document);
|
||||||
const processIFrame = function(iframe) {
|
|
||||||
const src = iframe.src;
|
|
||||||
if ( /^https?:\/\//.test(src) === false ) {
|
|
||||||
injectScriptlets(iframe.contentDocument);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let observerTimer,
|
|
||||||
observerLists = [];
|
|
||||||
const observerAsync = function() {
|
|
||||||
for ( const nodelist of observerLists ) {
|
|
||||||
for ( const node of nodelist ) {
|
|
||||||
if ( node.nodeType !== 1 ) { continue; }
|
|
||||||
if ( node.parentElement === null ) { continue; }
|
|
||||||
if ( node.localName === 'iframe' ) {
|
|
||||||
processIFrame(node);
|
|
||||||
}
|
|
||||||
if ( node.childElementCount === 0 ) { continue; }
|
|
||||||
let iframes = node.querySelectorAll('iframe');
|
|
||||||
for ( const iframe of iframes ) {
|
|
||||||
processIFrame(iframe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
observerLists = [];
|
|
||||||
observerTimer = undefined;
|
|
||||||
};
|
|
||||||
const ready = function(ev) {
|
|
||||||
if ( ev !== undefined ) {
|
|
||||||
window.removeEventListener(ev.type, ready);
|
|
||||||
}
|
|
||||||
const iframes = document.getElementsByTagName('iframe');
|
|
||||||
if ( iframes.length !== 0 ) {
|
|
||||||
observerLists.push(iframes);
|
|
||||||
observerTimer = setTimeout(observerAsync, 1);
|
|
||||||
}
|
|
||||||
const observer = new MutationObserver(function(mutations) {
|
|
||||||
for ( const mutation of mutations ) {
|
|
||||||
if ( mutation.addedNodes.length !== 0 ) {
|
|
||||||
observerLists.push(mutation.addedNodes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
observerLists.length !== 0 &&
|
|
||||||
observerTimer === undefined
|
|
||||||
) {
|
|
||||||
observerTimer = setTimeout(observerAsync, 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
observer.observe(
|
|
||||||
document.documentElement,
|
|
||||||
{ childList: true, subtree: true }
|
|
||||||
);
|
|
||||||
};
|
|
||||||
if ( document.readyState === 'loading' ) {
|
|
||||||
window.addEventListener('DOMContentLoaded', ready);
|
|
||||||
} else {
|
|
||||||
ready();
|
|
||||||
}
|
|
||||||
}.toString(),
|
}.toString(),
|
||||||
')(',
|
')(',
|
||||||
'"', 'hostname-slot', '", ',
|
'"', 'hostname-slot', '", ',
|
||||||
|
@ -457,10 +399,10 @@
|
||||||
code = 'debugger;\n' + code;
|
code = 'debugger;\n' + code;
|
||||||
}
|
}
|
||||||
vAPI.tabs.executeScript(details.tabId, {
|
vAPI.tabs.executeScript(details.tabId, {
|
||||||
code: code,
|
code,
|
||||||
frameId: details.frameId,
|
frameId: details.frameId,
|
||||||
matchAboutBlank: false,
|
matchAboutBlank: true,
|
||||||
runAt: 'document_start'
|
runAt: 'document_start',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue