[TabGuard] Introduce prompt granularity options (default: prompt only on POST requests).

This commit is contained in:
hackademix 2023-05-21 23:28:36 +02:00
parent e7591e0fdd
commit 3a83c0e4a5
No known key found for this signature in database
GPG Key ID: 231A83AFDA9C2434
7 changed files with 44 additions and 3 deletions

View File

@ -720,6 +720,15 @@
"TabGuard_optEnabled": {
"message": "Enabled everywhere"
},
"TabGuard_optPromptNever": {
"message": "Never prompt before anonymization"
},
"TabGuard_optPromptPost": {
"message": "Prompt before anonymizing POST submissions"
},
"TabGuard_optPromptAlways": {
"message": "Prompt before anonymizing any request"
},
"TabGuard_optIncognito": {
"message": "Enabled in Private Browsing only"
},

View File

@ -959,6 +959,15 @@
"message": "Disabilitata",
"description": ""
},
"TabGuard_optPromptNever": {
"message": "Se necessario anonimizza le richieste senza avvisare"
},
"TabGuard_optPromptPost": {
"message": "Avvisa prima di anonimizzare le richieste con invio di dati (POST)"
},
"TabGuard_optPromptAlways": {
"message": "Avvisa prima di anonimizzare qualunque richiesta"
},
"TabGuard_forget": {
"message": "Dimentica le eccezioni",
"description": ""

View File

@ -34,6 +34,7 @@ var Defaults = {
global: false,
xss: true,
TabGuardMode: "incognito",
TabGuardPrompt: "post",
cascadeRestrictions : false,
overrideTorBrowserPolicy: false, // note: Settings.update() on reset will flip this to true
}

View File

@ -158,7 +158,12 @@ var TabGuard = (() => {
let quietDomains = filteredGroups[tabDomain];
if (mainFrame) {
let mustPrompt = (!quietDomains || [...otherDomains].some(d => !quietDomains.has(d)));
const promptOption = ns.sync.TabGuardPrompt;
const mustPrompt = promptOption !== "never" &&
(promptOption !== "post" || request.method === "POST") &&
(!quietDomains || [...otherDomains].some(d => !quietDomains.has(d)));
if (mustPrompt) {
return (async () => {
let options = [
@ -169,7 +174,9 @@ var TabGuard = (() => {
title: _("TabGuard_title"),
message: _("TabGuard_message", [tabDomain, [...otherDomains].join(", ")]),
options});
if (ret.button !== 0) return {cancel: true};
if (ret.button !== 0) {
return {cancel: true};
}
let list = ret.option === 0 ? filteredGroups : allowedGroups;
otherDomains.add(tabDomain);
for (let d of otherDomains) list[d] = otherDomains;

View File

@ -177,6 +177,13 @@ SPDX-License-Identifier: GPL-3.0-or-later
<input id="tgm-off" type="radio" name="TabGuardMode" value="off"/><label for="tgm-off">__MSG_TabGuard_optDisabled__</label>
</span>
</div>
<div class="opt-group">
<span id="tgPrompt">
<input id="tgp-never" type="radio" name="TabGuardPrompt" value="never" /><label for="tgm-never">__MSG_TabGuard_optPromptNever__</label>
<input id="tgm-post" type="radio" name="TabGuardPrompt" value="post" checked="checked"/><label for="tgm-post">__MSG_TabGuard_optPromptPost__</label>
<input id="tgm-always" type="radio" name="TabGuardPrompt" value="always"/><label for="tgm-always">__MSG_TabGuard_optPromptAlways__</label>
</span>
</div>
<div id="tgForget"><button id="tgForgetButton">__MSG_TabGuard_forget__</button></div>
</fieldset>
</section>

View File

@ -142,6 +142,7 @@ document.querySelector("#version").textContent = _("Version",
});
UI.wireChoice("TabGuardMode");
UI.wireChoice("TabGuardPrompt");
document.querySelector("#tgForgetButton").onclick = e => {
e.target.disabled = true;

View File

@ -11,8 +11,13 @@
flex-flow: row wrap;
padding: .5em 0;
}
:is(section, .opt-group) ~ :is(.opt-group, section, fieldset) {
border-top: 2px dotted var(--bg-color1);
border-top: 2px solid var(--tab-color1);
}
fieldset > .opt-group ~ .opt-group {
border: none;
}
.opt-group > span {
@ -22,6 +27,8 @@
align-items: baseline;
}
.opt-group input[type="radio"] ~ label { margin-right: 1em};
@media (max-width: 550px) {
.sites td.url {