summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/content/PlaceHolder.js6
-rw-r--r--src/content/embeddingDocument.js21
2 files changed, 24 insertions, 3 deletions
diff --git a/src/content/PlaceHolder.js b/src/content/PlaceHolder.js
index 8f31951..8f57b4f 100644
--- a/src/content/PlaceHolder.js
+++ b/src/content/PlaceHolder.js
@@ -119,10 +119,14 @@ var PlaceHolder = (() => {
let replacement = createHTMLElement("a");
replacement.className = "__NoScript_PlaceHolder__";
cloneStyle(element, replacement);
- replacement.style.backgroundImage = `url(${ICON_URL})`;
+ let setImage = () => replacement.style.backgroundImage = `url(${ICON_URL})`;
if (ns.embeddingDocument) {
replacement.classList.add("document");
+ window.stop();
+ setTimeout(setImage, 0); // defer to bypass window.stop();
+ } else {
+ setImage();
}
replacement.href = url;
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();
}
});
}