Prominently warn user whenever restrictions are disabled.

This commit is contained in:
hackademix 2022-02-25 11:52:59 +01:00
parent eb0d06b302
commit b3a528aa1d
3 changed files with 13 additions and 3 deletions

View File

@ -159,7 +159,7 @@
"message": "General"
},
"NotEnforced": {
"message": "Restrictions disabled"
"message": "Restrictions disabled by user's settings: NoScript won't block anything on this page!"
},
"NoEnforcement": {
"message": "Disable restrictions globally (dangerous)"

View File

@ -212,7 +212,7 @@
"description": ""
},
"NotEnforced": {
"message": "Restrizioni disattivate",
"message": "Restrizioni disattivate per scelta dell'utente: NoScript non bloccherà nulla in questa pagina!",
"description": ""
},
"NoEnforcement": {

View File

@ -177,6 +177,14 @@ addEventListener("unload", e => {
}, true);
}
let enforcementWarning = button => {
if (button) {
let clone = button.cloneNode(true);
clone.onclick = button.onclick;
button = clone;
}
messageBox(button ? "warning" : "hidden", _("NotEnforced"), button);
};
let setupEnforcement = () => {
let policy = UI.policy;
let pressed = policy.enforced;
@ -191,6 +199,7 @@ addEventListener("unload", e => {
pendingReload(true);
};
button.disabled = false;
enforcementWarning(!policy.enforced && button);
setupTabEnforcement();
};
@ -200,7 +209,6 @@ addEventListener("unload", e => {
button.setAttribute("aria-pressed", pressed);
button.title = _(pressed ? "NoEnforcementForTab" : "EnforceForTab");
if (UI.policy.enforced) {
button.disabled = false;
button.onclick = async () => {
this.disabled = true;
await UI.updateSettings({
@ -211,6 +219,8 @@ addEventListener("unload", e => {
setupEnforcement();
pendingReload(true);
}
button.disabled = false;
enforcementWarning(UI.unrestrictedTab && button);
} else {
button.disabled = true;
}