diff options
author | hackademix | 2019-06-15 20:41:26 +0200 |
---|---|---|
committer | hackademix | 2019-06-15 20:41:26 +0200 |
commit | a4f088211e3b8c274d1755d542fac737679d7a56 (patch) | |
tree | f706e17acc3001a66541c3f8f7f13fd83fe757ee /src/content/embeddingDocument.js | |
parent | 04baf1a3f87dddf8f7b09f38251b7f811719d11b (diff) | |
download | noscript-a4f088211e3b8c274d1755d542fac737679d7a56.tar.gz noscript-a4f088211e3b8c274d1755d542fac737679d7a56.tar.xz noscript-a4f088211e3b8c274d1755d542fac737679d7a56.zip |
Fixed regression in full embedding document replacement due to timing changes.
Diffstat (limited to 'src/content/embeddingDocument.js')
-rw-r--r-- | src/content/embeddingDocument.js | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/content/embeddingDocument.js b/src/content/embeddingDocument.js index eed04b1..bc1b97f 100644 --- a/src/content/embeddingDocument.js +++ b/src/content/embeddingDocument.js @@ -1,5 +1,5 @@ if (ns.embeddingDocument) { - ns.on("capabilities", () => { + let replace = () => { for (let policyType of ["object", "media"]) { let request = { id: `noscript-${policyType}-doc`, @@ -8,7 +8,7 @@ if (ns.embeddingDocument) { documentUrl: document.URL, embeddingDocument: true, }; - + if (ns.allows(policyType)) { let handler = PlaceHolder.handlerFor(policyType); if (handler && handler.selectFor(request).length > 0) { @@ -19,9 +19,26 @@ if (ns.embeddingDocument) { if (ph.replacements.size > 0) { debug(`Created placeholder for ${policyType} at ${document.URL}`); seen.record({policyType, request, allowed: false}); + } + } + } + }; + ns.on("capabilities", () => { + if (!document.body.firstChild) { // we've been called early + setTimeout(replace, 0); + let types = { + "media": /^(?:video|audio)\//i, + "object": /^application\//i, + } + for (let [type, rx] of Object.entries(types)) { + if (rx.test(document.contentType) && !ns.allows(type)) { + window.stop(); break; } } + + } else { + replace(); } }); } |