diff options
author | hackademix | 2019-07-21 10:55:59 +0200 |
---|---|---|
committer | hackademix | 2019-07-23 18:11:14 +0200 |
commit | 8f71c8f4d35f3af21b59439e7afb6ebf3b6ea8e8 (patch) | |
tree | 6d23974553bb14144df13217dce76e92915f3d6f /src/content | |
parent | dc2cf89b3f50880ede81dd874238917e8445d7e4 (diff) | |
download | noscript-8f71c8f4d35f3af21b59439e7afb6ebf3b6ea8e8.tar.gz noscript-8f71c8f4d35f3af21b59439e7afb6ebf3b6ea8e8.tar.xz noscript-8f71c8f4d35f3af21b59439e7afb6ebf3b6ea8e8.zip |
Add "Collapse blocked objects" option to the Blocked Objects prompt.
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/PlaceHolder.js | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/content/PlaceHolder.js b/src/content/PlaceHolder.js index a13ae37..4c860ec 100644 --- a/src/content/PlaceHolder.js +++ b/src/content/PlaceHolder.js @@ -1,10 +1,11 @@ var PlaceHolder = (() => { const HANDLERS = new Map(); - + const CLASS_NAME = "__NoScript_PlaceHolder__"; + const SELECTOR = `a.${CLASS_NAME}`; let checkStyle = async () => { checkStyle = () => {}; if (!ns.embeddingDocument) return; - let replacement = document.querySelector("a.__NoScript_PlaceHolder__"); + let replacement = document.querySelector(SELECTOR); if (!replacement) return; if (window.getComputedStyle(replacement, null).opacity !== "0.8") { document.head.appendChild(createHTMLElement("style")).textContent = await @@ -126,7 +127,7 @@ var PlaceHolder = (() => { let TYPE = `<${this.policyType.toUpperCase()}>`; let replacement = createHTMLElement("a"); - replacement.className = "__NoScript_PlaceHolder__"; + replacement.className = CLASS_NAME; cloneStyle(element, replacement); let setImage = () => replacement.style.backgroundImage = `url(${ICON_URL})`; @@ -163,13 +164,20 @@ var PlaceHolder = (() => { async enable(replacement) { debug("Enabling %o", this.request, this.policyType); - let ok = await Messages.send("enable", { + let ret = await Messages.send("blockedObjects", { url: this.request.url, policyType: this.policyType, documentUrl: document.URL }); - debug("Received response", ok); - if (!ok) return; + debug("Received response", ret); + if (!ret) return; + if (ret.collapse) { + for (let collapsing of (ret.collapse === "all" ? document.querySelectorAll(SELECTOR) : [replacement])) { + this.replacements.delete(collapsing); + collapsing.remove(); + } + return; + } if (this.request.embeddingDocument) { window.location.reload(); return; |