Add "Collapse blocked objects" option to the Blocked Objects prompt.
This commit is contained in:
parent
dc2cf89b3f
commit
8f71c8f4d3
|
@ -63,7 +63,7 @@
|
|||
"message": "Blocked $1 of $2 items."
|
||||
},
|
||||
"BlockedObjects": {
|
||||
"message": "NoScript Blocked Objects"
|
||||
"message": "NoScript Blocked\u00A0Objects"
|
||||
},
|
||||
"BookmarkSync": {
|
||||
"message": "Backup NoScript configuration in a bookmark for easy synchronization"
|
||||
|
|
|
@ -173,7 +173,7 @@ var RequestGuard = (() => {
|
|||
TabStatus.recordAll(sender.tab.id, message.seen);
|
||||
return true;
|
||||
},
|
||||
async enable(message, sender) {
|
||||
async blockedObjects(message, sender) {
|
||||
let {url, documentUrl, policyType} = message;
|
||||
let TAG = `<${policyType.toUpperCase()}>`;
|
||||
let origin = Sites.origin(url);
|
||||
|
@ -184,7 +184,8 @@ var RequestGuard = (() => {
|
|||
}
|
||||
options = [
|
||||
{label: _("allowLocal", siteKey), checked: true},
|
||||
{label: _("allowLocal", origin)}
|
||||
{label: _("allowLocal", origin)},
|
||||
{label: _("CollapseBlockedObjects")},
|
||||
];
|
||||
let t = u => `${TAG}@${u}`;
|
||||
let ret = await Prompts.prompt({
|
||||
|
@ -193,6 +194,9 @@ var RequestGuard = (() => {
|
|||
options});
|
||||
debug(`Prompt returned %o`);
|
||||
if (ret.button !== 0) return;
|
||||
if (ret.option === 2) {
|
||||
return {collapse: "all"};
|
||||
}
|
||||
let key = [siteKey, origin][ret.option || 0];
|
||||
if (!key) return;
|
||||
let {siteMatch, contextMatch, perms} = ns.policy.get(key, documentUrl);
|
||||
|
@ -210,7 +214,7 @@ var RequestGuard = (() => {
|
|||
ns.policy.set(key, perms);
|
||||
await ns.savePolicy();
|
||||
}
|
||||
return true;
|
||||
return {enable: key};
|
||||
},
|
||||
}
|
||||
const Content = {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue