Don't enforce Incognito UI restrictions if the "Override Tor Browser Security Level preset" option is checked.

This commit is contained in:
hackademix 2020-06-01 20:58:19 +02:00
parent 2d5f47563c
commit b74d48366e
2 changed files with 12 additions and 10 deletions

View File

@ -35,6 +35,7 @@ addEventListener("unload", e => {
isBrowserAction = false;
try {
tabId = parseInt(document.URL.match(/#.*\btab(\d+)/)[1]);
tab = await browser.tabs.get(tabId);
} catch (e) {
close();
}
@ -53,7 +54,7 @@ addEventListener("unload", e => {
})
port = browser.runtime.connect({name: "noscript.popup"});
await UI.init(tabId);
await UI.init(tab);
function pendingReload(b) {
try {

View File

@ -12,8 +12,9 @@ var UI = (() => {
"CUSTOM": "Custom",
},
async init(tabId = -1) {
UI.tabId = tabId;
async init(tab) {
UI.tabId = tab ? tab.id : -1;
UI.incognito = tab && tab.incognito;
let scripts = [
"/ui/ui.css",
"/lib/Messages.js",
@ -39,7 +40,7 @@ var UI = (() => {
UI.xssUserChoices = m.xssUserChoices;
UI.local = m.local;
UI.sync = m.sync;
UI.forceIncognito = UI.incognito && !UI.sync.overrideTorBrowserPolicy;
if (UI.local) {
if (!UI.local.debug) {
debug = () => {}; // be quiet!
@ -262,14 +263,14 @@ var UI = (() => {
let messageKey = UI.presets[preset];
input.value = preset;
label.textContent = label.title = input.title = _(messageKey);
input.disabled = this.incognito && !INCOGNITO_PRESETS.includes(preset);
input.disabled = UI.forceIncognito && !INCOGNITO_PRESETS.includes(preset);
let clone = span.cloneNode(true);
clone.classList.add(preset);
let temp = clone.querySelector(".temp");
if (TEMP_PRESETS.includes(preset)) {
temp.title = _("allowTemp", `(${label.title.toUpperCase()})`);
temp.nextElementSibling.textContent = _("allowTemp", ""); // label;
temp.disabled = this.incognito;
temp.disabled = UI.forceIncognito;
} else {
temp.nextElementSibling.remove();
temp.remove();
@ -422,7 +423,7 @@ var UI = (() => {
}
if (isCap) {
perms.set(target.value, target.checked);
if (this.incognito) {
if (UI.forceIncognito) {
row.perms.temp = tempToggle.checked = true;
}
} else if (policyPreset) {
@ -441,9 +442,9 @@ var UI = (() => {
} else if (preset.value === "CUSTOM") {
if (isTemp) {
row.perms.temp = target.checked || this.incognito;
row.perms.temp = target.checked || UI.forceIncognito;
} else {
if (this.incognito) row.perms.temp = true;
if (UI.forceIncognito) row.perms.temp = true;
let temp = row.perms.temp;
tempToggle.checked = temp;
let perms = row._customPerms ||
@ -533,7 +534,7 @@ var UI = (() => {
case "KeyT":
{
let temp = preset.parentNode.querySelector("input.temp");
if (temp) temp.checked = !temp.checked || this.incognito;
if (temp) temp.checked = !temp.checked || UI.forceIncognito;
}
}
}