Improved blocking of media documents unaffected by webRequest.

This commit is contained in:
hackademix 2020-10-05 00:25:48 +02:00
parent fd51f8ffc1
commit 95d64c42d0
1 changed files with 18 additions and 0 deletions

View File

@ -1,6 +1,24 @@
if (ns.embeddingDocument) { if (ns.embeddingDocument) {
let suspended;
let suspender = new MutationObserver(records => {
suspended = document.body.firstElementChild;
if (suspended && !suspended._src) {
suspended._src = suspended.currentSrc || document.URL;
debug("Suspending ", suspended._src, suspended);
suspended.autoplay = false;
suspended.src = "data:";
suspender.disconnect();
}
});
suspender.observe(document, {childList: true, subtree: true});
let replace = () => { let replace = () => {
if (suspended) {
suspended.src = suspended._src;
suspended.autoplay = true;
} else {
suspender.disconnect();
}
for (let policyType of ["object", "media"]) { for (let policyType of ["object", "media"]) {
let request = { let request = {
id: `noscript-${policyType}-doc`, id: `noscript-${policyType}-doc`,