Fixed regression in full embedding document replacement due to timing changes.
This commit is contained in:
parent
04baf1a3f8
commit
a4f088211e
|
@ -119,10 +119,14 @@ var PlaceHolder = (() => {
|
||||||
let replacement = createHTMLElement("a");
|
let replacement = createHTMLElement("a");
|
||||||
replacement.className = "__NoScript_PlaceHolder__";
|
replacement.className = "__NoScript_PlaceHolder__";
|
||||||
cloneStyle(element, replacement);
|
cloneStyle(element, replacement);
|
||||||
replacement.style.backgroundImage = `url(${ICON_URL})`;
|
let setImage = () => replacement.style.backgroundImage = `url(${ICON_URL})`;
|
||||||
|
|
||||||
if (ns.embeddingDocument) {
|
if (ns.embeddingDocument) {
|
||||||
replacement.classList.add("document");
|
replacement.classList.add("document");
|
||||||
|
window.stop();
|
||||||
|
setTimeout(setImage, 0); // defer to bypass window.stop();
|
||||||
|
} else {
|
||||||
|
setImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
replacement.href = url;
|
replacement.href = url;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
if (ns.embeddingDocument) {
|
if (ns.embeddingDocument) {
|
||||||
ns.on("capabilities", () => {
|
let replace = () => {
|
||||||
for (let policyType of ["object", "media"]) {
|
for (let policyType of ["object", "media"]) {
|
||||||
let request = {
|
let request = {
|
||||||
id: `noscript-${policyType}-doc`,
|
id: `noscript-${policyType}-doc`,
|
||||||
|
@ -19,9 +19,26 @@ if (ns.embeddingDocument) {
|
||||||
if (ph.replacements.size > 0) {
|
if (ph.replacements.size > 0) {
|
||||||
debug(`Created placeholder for ${policyType} at ${document.URL}`);
|
debug(`Created placeholder for ${policyType} at ${document.URL}`);
|
||||||
seen.record({policyType, request, allowed: false});
|
seen.record({policyType, request, allowed: false});
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
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();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue