From b3a528aa1d36fb9c1e145dce5eb1de8207d5ff22 Mon Sep 17 00:00:00 2001 From: hackademix Date: Fri, 25 Feb 2022 11:52:59 +0100 Subject: [PATCH] Prominently warn user whenever restrictions are disabled. --- src/_locales/en/messages.json | 2 +- src/_locales/it/messages.json | 2 +- src/ui/popup.js | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 44d4e82..f288bc4 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -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)" diff --git a/src/_locales/it/messages.json b/src/_locales/it/messages.json index 12e6be8..3f95f97 100644 --- a/src/_locales/it/messages.json +++ b/src/_locales/it/messages.json @@ -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": { diff --git a/src/ui/popup.js b/src/ui/popup.js index 77f22d5..3a88658 100644 --- a/src/ui/popup.js +++ b/src/ui/popup.js @@ -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; }