1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-05 11:37:01 +02:00

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:
Raymond Hill 2020-10-12 10:08:51 -04:00
parent 422e3f676f
commit 6e010ecc0f
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 4 additions and 62 deletions

View File

@ -754,7 +754,7 @@
}
}
Object.defineProperty(owner, prop, {
configurable: true,
configurable: false,
get() {
if ( prevGetter !== undefined ) {
prevGetter();

View File

@ -94,64 +94,6 @@
}
};
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(),
')(',
'"', 'hostname-slot', '", ',
@ -457,10 +399,10 @@
code = 'debugger;\n' + code;
}
vAPI.tabs.executeScript(details.tabId, {
code: code,
code,
frameId: details.frameId,
matchAboutBlank: false,
runAt: 'document_start'
matchAboutBlank: true,
runAt: 'document_start',
});
};