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" "message": "General"
}, },
"NotEnforced": { "NotEnforced": {
"message": "Restrictions disabled" "message": "Restrictions disabled by user's settings: NoScript won't block anything on this page!"
}, },
"NoEnforcement": { "NoEnforcement": {
"message": "Disable restrictions globally (dangerous)" "message": "Disable restrictions globally (dangerous)"

View File

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

View File

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