mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-04 04:26:35 +02:00
Big linting
This commit is contained in:
parent
b5e6d049ce
commit
aef6bd3d59
58 changed files with 2074 additions and 1856 deletions
|
@ -10,7 +10,7 @@
|
|||
require("../lib/theme").init();
|
||||
const input = document.getElementById("settings");
|
||||
settings.onloaded(function(){
|
||||
var data = {};
|
||||
const data = {};
|
||||
settings.forEach(function(def){
|
||||
data[def.name] = def.get();
|
||||
});
|
||||
|
@ -18,8 +18,8 @@
|
|||
|
||||
input.addEventListener("input", function(){
|
||||
try {
|
||||
var newSettings = JSON.parse(this.value);
|
||||
var isValid = true;
|
||||
let newSettings = JSON.parse(this.value);
|
||||
let isValid = true;
|
||||
|
||||
while (settingsMigration.transitions.hasOwnProperty(newSettings.storageVersion)){
|
||||
let oldVersion = newSettings.storageVersion;
|
||||
|
@ -57,14 +57,14 @@
|
|||
this.classList.add("invalid");
|
||||
}
|
||||
}
|
||||
catch (e){
|
||||
logging.warning("Invalid JSON:", e);
|
||||
catch (error){
|
||||
logging.warning("Invalid JSON:", error);
|
||||
this.classList.add("invalid");
|
||||
}
|
||||
});
|
||||
input.addEventListener("blur", function(){
|
||||
if (!this.classList.contains("invalid")){
|
||||
var data = {};
|
||||
const data = {};
|
||||
settings.forEach(function(def){
|
||||
data[def.name] = def.get();
|
||||
});
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
require("./theme").init("options");
|
||||
const modal = require("../lib/modal");
|
||||
|
||||
var callbacks = {
|
||||
const callbacks = {
|
||||
openNavigatorSettings: function(){
|
||||
logging.verbose("open navigator settings");
|
||||
window.open("navigator.html", "_blank");
|
||||
|
@ -36,7 +36,7 @@
|
|||
},
|
||||
clearPersistentRndForContainer: function(){
|
||||
browser.contextualIdentities.query({}).then(function(identities){
|
||||
modal.select(
|
||||
return modal.select(
|
||||
extension.getTranslation("clearPersistentRndForContainer_title"),
|
||||
identities.map(function(identity){
|
||||
return {
|
||||
|
@ -44,9 +44,12 @@
|
|||
object: identity
|
||||
};
|
||||
})
|
||||
).then(function(identity){
|
||||
extension.message.send({"canvasBlocker-clear-container-rnd": identity.cookieStoreId});
|
||||
}, ()=>{});
|
||||
);
|
||||
}).then(function(identity){
|
||||
extension.message.send({"canvasBlocker-clear-container-rnd": identity.cookieStoreId});
|
||||
return;
|
||||
}).catch(function(error){
|
||||
logging.warning("Unable to clear persistent rnd for container:", error);
|
||||
});
|
||||
},
|
||||
inspectSettings: function(){
|
||||
|
@ -73,7 +76,7 @@
|
|||
link.target = "_blank";
|
||||
const now = new Date();
|
||||
function format(number, digits){
|
||||
var str = number.toFixed(0);
|
||||
const str = number.toFixed(0);
|
||||
return "0".repeat(digits - str.length) + str;
|
||||
}
|
||||
link.download = "CanvasBlocker-settings_" +
|
||||
|
@ -99,13 +102,12 @@
|
|||
input.type = "file";
|
||||
input.addEventListener("change", function(){
|
||||
if (this.files.length){
|
||||
var file = this.files[0];
|
||||
var reader = new FileReader();
|
||||
reader.onload = function(result){
|
||||
const reader = new FileReader();
|
||||
reader.onload = function(){
|
||||
resolve(this.result);
|
||||
};
|
||||
reader.onerror = function(err){
|
||||
reject(err);
|
||||
reader.onerror = function(error){
|
||||
reject(error);
|
||||
};
|
||||
reader.readAsText(this.files[0]);
|
||||
}
|
||||
|
@ -134,8 +136,9 @@
|
|||
keys.forEach(function(key){
|
||||
settings[key] = json[key];
|
||||
});
|
||||
}).catch(function(err){
|
||||
alert(err);
|
||||
return;
|
||||
}).catch(function(error){
|
||||
alert(error);
|
||||
});
|
||||
},
|
||||
resetSettings: function(){
|
||||
|
@ -149,6 +152,9 @@
|
|||
if (clear){
|
||||
browser.storage.local.clear();
|
||||
}
|
||||
return;
|
||||
}).catch(function(error){
|
||||
logging.warning("Unable to reset settings:", error);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -224,22 +230,25 @@
|
|||
linkDiv.appendChild(link);
|
||||
head.appendChild(linkDiv);
|
||||
}
|
||||
return;
|
||||
}).catch(function(error){
|
||||
logging.warning("Unable to identify tab:", error);
|
||||
});
|
||||
|
||||
var groupTabs = document.createElement("div");
|
||||
const groupTabs = document.createElement("div");
|
||||
groupTabs.classList = "groupTabs";
|
||||
document.body.appendChild(groupTabs);
|
||||
|
||||
var groups = document.createElement("ul");
|
||||
const groups = document.createElement("ul");
|
||||
groups.className = "groups";
|
||||
groupTabs.appendChild(groups);
|
||||
|
||||
var table = document.createElement("table");
|
||||
const table = document.createElement("table");
|
||||
table.className = "settings " + (settings.displayDescriptions? "display": "hide") + "Descriptions";
|
||||
settings.on("displayDescriptions", function(){
|
||||
table.className = "settings " + (settings.displayDescriptions? "display": "hide") + "Descriptions";
|
||||
});
|
||||
var tableContainer = document.createElement("div");
|
||||
const tableContainer = document.createElement("div");
|
||||
tableContainer.classList = "tabContents";
|
||||
groupTabs.appendChild(tableContainer);
|
||||
|
||||
|
@ -277,41 +286,6 @@
|
|||
|
||||
const {hide: hideContainer, expand: expandContainer} = settings.getContainers();
|
||||
|
||||
const addGroup = function addGroup(groupDefinition){
|
||||
const sections = [];
|
||||
const group = {
|
||||
select: function(){
|
||||
groups.querySelectorAll(".selected").forEach(function(group){
|
||||
group.classList.remove("selected");
|
||||
});
|
||||
table.querySelectorAll("tbody").forEach(function(section){
|
||||
section.classList.remove("selectedGroup");
|
||||
});
|
||||
sections.forEach(function(section){
|
||||
section.node.classList.add("selectedGroup");
|
||||
});
|
||||
name.classList.add("selected");
|
||||
},
|
||||
addSection: function(sectionDefinition){
|
||||
const section = addSection(sectionDefinition.name);
|
||||
sections.push(section);
|
||||
return section;
|
||||
}
|
||||
};
|
||||
|
||||
const groupIndex = groups.childNodes.length;
|
||||
const name = document.createElement("li");
|
||||
name.textContent = extension.getTranslation("group_" + groupDefinition.name);
|
||||
name.className = "groupName group" + groupIndex;
|
||||
|
||||
|
||||
name.addEventListener("click", group.select);
|
||||
|
||||
groups.appendChild(name);
|
||||
|
||||
return group;
|
||||
};
|
||||
|
||||
const addSection = function addSection(name){
|
||||
const body = document.createElement("tbody");
|
||||
body.className = "sectionBody";
|
||||
|
@ -356,9 +330,9 @@
|
|||
},
|
||||
updateDisplay: function(){
|
||||
const searchMode = document.body.classList.contains("searching");
|
||||
var anyVisible = false;
|
||||
let anyVisible = false;
|
||||
rows.forEach(function(row){
|
||||
var isHidden = row.classList.contains("hidden");
|
||||
const isHidden = row.classList.contains("hidden");
|
||||
if (!isHidden){
|
||||
if (searchMode){
|
||||
if (!row.classList.contains("found")){
|
||||
|
@ -382,13 +356,160 @@
|
|||
return section;
|
||||
};
|
||||
|
||||
const addGroup = function addGroup(groupDefinition){
|
||||
const sections = [];
|
||||
|
||||
const groupIndex = groups.childNodes.length;
|
||||
const name = document.createElement("li");
|
||||
name.textContent = extension.getTranslation("group_" + groupDefinition.name);
|
||||
name.className = "groupName group" + groupIndex;
|
||||
|
||||
const group = {
|
||||
select: function(){
|
||||
groups.querySelectorAll(".selected").forEach(function(group){
|
||||
group.classList.remove("selected");
|
||||
});
|
||||
table.querySelectorAll("tbody").forEach(function(section){
|
||||
section.classList.remove("selectedGroup");
|
||||
});
|
||||
sections.forEach(function(section){
|
||||
section.node.classList.add("selectedGroup");
|
||||
});
|
||||
name.classList.add("selected");
|
||||
},
|
||||
addSection: function(sectionDefinition){
|
||||
const section = addSection(sectionDefinition.name);
|
||||
sections.push(section);
|
||||
return section;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
name.addEventListener("click", group.select);
|
||||
|
||||
groups.appendChild(name);
|
||||
|
||||
return group;
|
||||
};
|
||||
|
||||
const beforeChangeEventListeners = {};
|
||||
function setupSetterForDisplay(setting){
|
||||
let originalSet = setting.set;
|
||||
setting.originalSet = originalSet;
|
||||
if (originalSet){
|
||||
const eventListeners = [];
|
||||
beforeChangeEventListeners[setting.name] = eventListeners;
|
||||
setting.set = function(...args){
|
||||
if (eventListeners.every(function(listener){
|
||||
return listener.call(setting, ...args);
|
||||
})){
|
||||
return originalSet.apply(this, args);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function setupHideForDisplay(setting){
|
||||
const display = setting.display;
|
||||
const hideChangeListeners = [];
|
||||
setting.setHide = function setHide(value){
|
||||
if (hideContainer){
|
||||
hideContainer.setHideByName(display.name, value);
|
||||
if (setting.computeDependencies){
|
||||
setting.computeDependencies();
|
||||
}
|
||||
}
|
||||
};
|
||||
setting.onHideChange = function(listener){
|
||||
hideChangeListeners.push(listener);
|
||||
};
|
||||
setting.getHide = function getHide(){
|
||||
if (hideContainer){
|
||||
return hideContainer.getHideByName(display.name);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
if (hideContainer){
|
||||
hideContainer.onHideChange(display.name, function(value){
|
||||
if (setting.computeDependencies){
|
||||
setting.computeDependencies();
|
||||
}
|
||||
hideChangeListeners.forEach(function(listener){
|
||||
listener(value);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
function setupExpandForDisplay(setting){
|
||||
const display = setting.display;
|
||||
const expandChangeListeners = [];
|
||||
setting.setExpand = function setExpand(value){
|
||||
if (expandContainer){
|
||||
expandContainer.setExpandByName(display.name, value);
|
||||
}
|
||||
};
|
||||
setting.onExpandChange = function(listener){
|
||||
expandChangeListeners.push(listener);
|
||||
};
|
||||
setting.getExpand = function getExpand(){
|
||||
if (expandContainer){
|
||||
return expandContainer.getExpandByName(display.name);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
if (expandContainer){
|
||||
expandContainer.onExpandChange(display.name, function(value){
|
||||
expandChangeListeners.forEach(function(listener){
|
||||
listener(value);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function setupComputeDependenciesForDisplay(setting, section, row){
|
||||
let displayDependencies = setting.display.displayDependencies || [{}];
|
||||
displayDependencies = Array.isArray(displayDependencies)?
|
||||
displayDependencies:
|
||||
[displayDependencies];
|
||||
setting.computeDependencies = function computeDependencies(){
|
||||
logging.verbose("evaluate display dependencies for", setting);
|
||||
row.classList[(
|
||||
(
|
||||
displayHidden.get() ||
|
||||
!setting.getHide()
|
||||
) &&
|
||||
displayDependencies.some(function(displayDependency){
|
||||
return Object.keys(displayDependency).every(function(key){
|
||||
return displayDependency[key].indexOf(settings[key]) !== -1;
|
||||
});
|
||||
})
|
||||
)? "remove": "add"]("hidden");
|
||||
section.updateDisplay();
|
||||
};
|
||||
|
||||
displayDependencies.forEach(function(displayDependency){
|
||||
Object.keys(displayDependency).forEach(function(name){
|
||||
settings.on(name, setting.computeDependencies);
|
||||
});
|
||||
});
|
||||
|
||||
setting.computeDependencies();
|
||||
displayHidden.on(setting.computeDependencies);
|
||||
}
|
||||
|
||||
settingsDisplay.map(function(groupDefinition){
|
||||
const group = addGroup(groupDefinition);
|
||||
groupDefinition.sections.forEach(function(sectionDefinition){
|
||||
const section = group.addSection(sectionDefinition);
|
||||
sectionDefinition.settings.forEach(function(display){
|
||||
var setting = settings.getDefinition(display.name);
|
||||
let setting = settings.getDefinition(display.name);
|
||||
if (!setting){
|
||||
if (display.inputs){
|
||||
setting = {
|
||||
|
@ -419,113 +540,17 @@
|
|||
if (setting){
|
||||
setting.display = display;
|
||||
|
||||
let originalSet = setting.set;
|
||||
setting.originalSet = originalSet;
|
||||
if (originalSet){
|
||||
const eventListeners = [];
|
||||
beforeChangeEventListeners[setting.name] = eventListeners;
|
||||
setting.set = function(...args){
|
||||
if (eventListeners.every(function(listener){
|
||||
return listener.call(setting, ...args);
|
||||
})){
|
||||
return originalSet.apply(this, args);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
setupSetterForDisplay(setting);
|
||||
setupHideForDisplay(setting);
|
||||
setupExpandForDisplay(setting);
|
||||
|
||||
let hideChangeListeners = [];
|
||||
setting.setHide = function setHide(value){
|
||||
if (hideContainer){
|
||||
hideContainer.setHideByName(display.name, value);
|
||||
if (computeDependencies){
|
||||
computeDependencies();
|
||||
}
|
||||
}
|
||||
};
|
||||
setting.onHideChange = function(listener){
|
||||
hideChangeListeners.push(listener);
|
||||
};
|
||||
setting.getHide = function getHide(){
|
||||
if (hideContainer){
|
||||
return hideContainer.getHideByName(display.name);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
if (hideContainer){
|
||||
hideContainer.onHideChange(display.name, function(value){
|
||||
if (computeDependencies){
|
||||
computeDependencies();
|
||||
}
|
||||
hideChangeListeners.forEach(function(listener){
|
||||
listener(value);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
let expandChangeListeners = [];
|
||||
setting.setExpand = function setExpand(value){
|
||||
if (expandContainer){
|
||||
expandContainer.setExpandByName(display.name, value);
|
||||
}
|
||||
};
|
||||
setting.onExpandChange = function(listener){
|
||||
expandChangeListeners.push(listener);
|
||||
};
|
||||
setting.getExpand = function getExpand(){
|
||||
if (expandContainer){
|
||||
return expandContainer.getExpandByName(display.name);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
if (expandContainer){
|
||||
expandContainer.onExpandChange(display.name, function(value){
|
||||
expandChangeListeners.forEach(function(listener){
|
||||
listener(value);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var row = optionsGui.createSettingRow(setting);
|
||||
const row = optionsGui.createSettingRow(setting);
|
||||
settingStrings.getStrings(setting).forEach(function(string){
|
||||
search.register(string, row);
|
||||
});
|
||||
section.addRow(row);
|
||||
if (!display.displayDependencies){
|
||||
display.displayDependencies = {};
|
||||
}
|
||||
var displayDependencies = display.displayDependencies;
|
||||
displayDependencies = Array.isArray(displayDependencies)?
|
||||
displayDependencies:
|
||||
[displayDependencies];
|
||||
var computeDependencies = function(){
|
||||
logging.verbose("evaluate display dependencies for", setting);
|
||||
row.classList[(
|
||||
(
|
||||
displayHidden.get() ||
|
||||
!setting.getHide()
|
||||
) &&
|
||||
displayDependencies.some(function(displayDependency){
|
||||
return Object.keys(displayDependency).every(function(key){
|
||||
return displayDependency[key].indexOf(settings[key]) !== -1;
|
||||
});
|
||||
})
|
||||
)? "remove": "add"]("hidden");
|
||||
section.updateDisplay();
|
||||
};
|
||||
computeDependencies();
|
||||
displayDependencies.forEach(function(displayDependency){
|
||||
Object.keys(displayDependency).forEach(function(name){
|
||||
settings.on(name, computeDependencies);
|
||||
});
|
||||
});
|
||||
displayHidden.on(computeDependencies);
|
||||
|
||||
setupComputeDependenciesForDisplay(setting, section, row);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -538,6 +563,9 @@
|
|||
return response.json();
|
||||
}).then(function(manifest){
|
||||
version.textContent = "Version " + manifest.version;
|
||||
return;
|
||||
}).catch(function(error){
|
||||
version.textContent = "Unable to get version: " + error;
|
||||
});
|
||||
document.body.appendChild(version);
|
||||
|
||||
|
@ -567,6 +595,9 @@
|
|||
if (addException){
|
||||
settings.set("protectWindow", false, reCaptchaEntry);
|
||||
}
|
||||
return;
|
||||
}).catch(function(error){
|
||||
logging.warning("Error while adding reCaptcha exception:", error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -581,8 +612,11 @@
|
|||
}
|
||||
).then((reallyShare) => {
|
||||
if (reallyShare){
|
||||
this.originalSet(value, ...args);
|
||||
return this.originalSet(value, ...args);
|
||||
}
|
||||
return;
|
||||
}).catch(function(error){
|
||||
logging.warning("Unable to set sharePersistentRndBetweenDomains:", error);
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
(function(){
|
||||
"use strict";
|
||||
|
||||
var scope;
|
||||
let scope;
|
||||
if ((typeof exports) !== "undefined"){
|
||||
scope = exports;
|
||||
}
|
||||
|
@ -16,15 +16,15 @@
|
|||
const logging = require("../lib/logging");
|
||||
|
||||
function createDescription(setting){
|
||||
var c = document.createElement("div");
|
||||
const c = document.createElement("div");
|
||||
c.className = "content";
|
||||
|
||||
var title = document.createElement("span");
|
||||
const title = document.createElement("span");
|
||||
title.className = "title";
|
||||
title.textContent = extension.getTranslation(setting.name + "_title");
|
||||
c.appendChild(title);
|
||||
|
||||
var descriptionText = extension.getTranslation(setting.name + "_description");
|
||||
let descriptionText = extension.getTranslation(setting.name + "_description");
|
||||
if (setting.urlSpecific){
|
||||
const urlSpecificDescription = extension.getTranslation(setting.name + "_urlSpecific");
|
||||
if (urlSpecificDescription){
|
||||
|
@ -32,11 +32,11 @@
|
|||
}
|
||||
}
|
||||
if (descriptionText){
|
||||
var info = document.createElement("div");
|
||||
const info = document.createElement("div");
|
||||
info.className = "info";
|
||||
c.appendChild(info);
|
||||
|
||||
var description = document.createElement("div");
|
||||
const description = document.createElement("div");
|
||||
description.className = "description";
|
||||
description.textContent = descriptionText;
|
||||
info.appendChild(description);
|
||||
|
@ -45,10 +45,10 @@
|
|||
}
|
||||
|
||||
function createSelect(setting){
|
||||
var select = document.createElement("select");
|
||||
const select = document.createElement("select");
|
||||
select.dataset.type = typeof setting.defaultValue;
|
||||
setting.options.forEach(function(value){
|
||||
var option = document.createElement("option");
|
||||
const option = document.createElement("option");
|
||||
if (typeof value === typeof setting.defaultValue){
|
||||
option.value = value;
|
||||
if (setting.defaultValue === value){
|
||||
|
@ -65,7 +65,7 @@
|
|||
return select;
|
||||
}
|
||||
|
||||
var inputTypes = {
|
||||
const inputTypes = {
|
||||
number: {
|
||||
input: function(value){
|
||||
const input = document.createElement("input");
|
||||
|
@ -121,10 +121,192 @@
|
|||
},
|
||||
object: false
|
||||
};
|
||||
|
||||
function createKeyInput(setting, url){
|
||||
const input = document.createElement("table");
|
||||
let inSection = false;
|
||||
setting.keys.forEach(function(key){
|
||||
if (setting.display.displayedSection){
|
||||
if (typeof key === "object"){
|
||||
if (key.level === 1){
|
||||
inSection = key.name === setting.display.displayedSection;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!inSection){
|
||||
return;
|
||||
}
|
||||
}
|
||||
let row = document.createElement("tr");
|
||||
if (typeof key === "object"){
|
||||
let cell = document.createElement("td");
|
||||
cell.colSpan = 2;
|
||||
let h = document.createElement("h" + (2 + (key.level || 1)));
|
||||
h.textContent = key.message? extension.getTranslation(key.message): key.name;
|
||||
cell.appendChild(h);
|
||||
row.appendChild(cell);
|
||||
input.appendChild(row);
|
||||
return;
|
||||
}
|
||||
|
||||
let nameCell = document.createElement("td");
|
||||
nameCell.textContent = setting.display.replaceKeyPattern?
|
||||
key.replace(setting.display.replaceKeyPattern, ""):
|
||||
key;
|
||||
row.appendChild(nameCell);
|
||||
|
||||
let keyType = inputTypes[typeof setting.defaultKeyValue];
|
||||
let keyInput = keyType.input(setting.defaultKeyValue);
|
||||
|
||||
let inputCell = document.createElement("td");
|
||||
inputCell.appendChild(keyInput);
|
||||
row.appendChild(inputCell);
|
||||
|
||||
setting.on(function(){
|
||||
const container = setting.get(url);
|
||||
keyType.updateCallback(
|
||||
keyInput,
|
||||
container && container.hasOwnProperty(key)?
|
||||
container[key]:
|
||||
setting.defaultKeyValue,
|
||||
url
|
||||
);
|
||||
});
|
||||
keyInput.addEventListener("change", function(){
|
||||
const value = keyType.getValue(keyInput);
|
||||
let container = setting.get(url);
|
||||
if (!container){
|
||||
container = setting.defaultValue;
|
||||
}
|
||||
container[key] = value;
|
||||
if (setting.set(container, url)){
|
||||
logging.message("changed setting", setting.name, "(", key, "):", value);
|
||||
}
|
||||
else {
|
||||
container = setting.get(url);
|
||||
keyType.updateCallback(
|
||||
keyInput,
|
||||
container && container.hasOwnProperty(key)?
|
||||
container[key]:
|
||||
setting.defaultKeyValue,
|
||||
url
|
||||
);
|
||||
logging.message("setting", setting.name, "(", key, ") was not changed");
|
||||
}
|
||||
});
|
||||
input.appendChild(row);
|
||||
});
|
||||
return input;
|
||||
}
|
||||
|
||||
function getPopulateUrlTable(setting, type, body){
|
||||
return function populateUrlTable({newValue}){
|
||||
body.innerHTML = "";
|
||||
newValue.forEach(function(entry){
|
||||
let row = document.createElement("tr");
|
||||
let urlCell = document.createElement("td");
|
||||
urlCell.classList.add("url");
|
||||
urlCell.addEventListener("click", function(){
|
||||
const input = document.createElement("input");
|
||||
input.classList.add("urlInput");
|
||||
input.style.width = urlCell.clientWidth + "px";
|
||||
input.style.height = urlCell.clientHeight + "px";
|
||||
urlCell.innerHTML = "";
|
||||
urlCell.appendChild(input);
|
||||
input.title = extension.getTranslation("inputURL");
|
||||
input.value = entry.url;
|
||||
input.focus();
|
||||
input.addEventListener("blur", function(){
|
||||
const url = input.value.trim();
|
||||
if (url){
|
||||
entry.url = url;
|
||||
setting.urlContainer.refresh();
|
||||
}
|
||||
urlCell.removeChild(input);
|
||||
urlCell.textContent = entry.url;
|
||||
});
|
||||
});
|
||||
urlCell.textContent = entry.url;
|
||||
row.appendChild(urlCell);
|
||||
let input = createInput(setting, entry.url);
|
||||
type.updateCallback(input, setting.get(entry.url));
|
||||
if (!entry.hasOwnProperty(setting.name)){
|
||||
input.classList.add("notSpecifiedForUrl");
|
||||
}
|
||||
let inputCell = document.createElement("td");
|
||||
inputCell.appendChild(input);
|
||||
row.appendChild(inputCell);
|
||||
let clearCell = document.createElement("td");
|
||||
let clearButton = document.createElement("button");
|
||||
clearButton.className = "reset";
|
||||
clearButton.textContent = "\xD7";
|
||||
clearButton.addEventListener("click", function(){
|
||||
setting.reset(entry.url);
|
||||
});
|
||||
clearCell.appendChild(clearButton);
|
||||
row.appendChild(clearCell);
|
||||
body.appendChild(row);
|
||||
});
|
||||
};
|
||||
}
|
||||
function createUrlSpecificInput(setting, input, type){
|
||||
const container = document.createElement("div");
|
||||
container.className = "urlValues " + (setting.getExpand()? "expanded": "collapsed");
|
||||
container.appendChild(input);
|
||||
const collapser = document.createElement("button");
|
||||
collapser.classList.add("collapser");
|
||||
container.appendChild(collapser);
|
||||
collapser.addEventListener("click", function(){
|
||||
setting.setExpand(!setting.getExpand());
|
||||
});
|
||||
setting.onExpandChange(function(value){
|
||||
container.classList[value? "remove": "add"]("collapsed");
|
||||
container.classList[value? "add": "remove"]("expanded");
|
||||
});
|
||||
let urlTable = document.createElement("table");
|
||||
let caption = document.createElement("caption");
|
||||
caption.textContent = extension.getTranslation(setting.urlContainer.name + "_title");
|
||||
urlTable.appendChild(caption);
|
||||
let body = document.createElement("tbody");
|
||||
urlTable.appendChild(body);
|
||||
let foot = document.createElement("tfoot");
|
||||
let footRow = document.createElement("tr");
|
||||
let footCell = document.createElement("td");
|
||||
footCell.colSpan = 3;
|
||||
let newInput = document.createElement("input");
|
||||
newInput.className = "inputURL";
|
||||
newInput.title = extension.getTranslation("inputURL");
|
||||
const addURLSetting = function(){
|
||||
const url = newInput.value.trim();
|
||||
if (url){
|
||||
setting.set(setting.get(url), url);
|
||||
newInput.value = "";
|
||||
newInput.focus();
|
||||
}
|
||||
};
|
||||
newInput.addEventListener("keypress", function(event){
|
||||
if ([10, 13].indexOf(event.keyCode) !== -1){
|
||||
addURLSetting();
|
||||
}
|
||||
});
|
||||
footCell.appendChild(newInput);
|
||||
let footPlus = document.createElement("button");
|
||||
footPlus.classList.add("add");
|
||||
footPlus.textContent = "+";
|
||||
footPlus.addEventListener("click", addURLSetting);
|
||||
footCell.appendChild(footPlus);
|
||||
footRow.appendChild(footCell);
|
||||
foot.appendChild(footRow);
|
||||
urlTable.appendChild(foot);
|
||||
container.appendChild(urlTable);
|
||||
|
||||
setting.urlContainer.on(getPopulateUrlTable(setting, type, body));
|
||||
return container;
|
||||
}
|
||||
|
||||
function createInput(setting, url = ""){
|
||||
var type = inputTypes[typeof setting.defaultValue];
|
||||
var input;
|
||||
const type = inputTypes[typeof setting.defaultValue];
|
||||
let input;
|
||||
if (setting.options){
|
||||
input = createSelect(setting);
|
||||
}
|
||||
|
@ -136,7 +318,7 @@
|
|||
if (type){
|
||||
setting.on(function(){type.updateCallback(input, setting.get(url));}, url);
|
||||
input.addEventListener("change", function(){
|
||||
var value = type.getValue(input);
|
||||
const value = type.getValue(input);
|
||||
if (setting.set(value, url)){
|
||||
logging.message("changed setting", setting.name, ":", value);
|
||||
}
|
||||
|
@ -147,211 +329,41 @@
|
|||
});
|
||||
}
|
||||
else if (setting.keys){
|
||||
input = document.createElement("table");
|
||||
let inSection = false;
|
||||
setting.keys.forEach(function(key){
|
||||
if (setting.display.displayedSection){
|
||||
if (typeof key === "object"){
|
||||
if (key.level === 1){
|
||||
inSection = key.name === setting.display.displayedSection;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!inSection){
|
||||
return;
|
||||
}
|
||||
}
|
||||
let row = document.createElement("tr");
|
||||
if (typeof key === "object"){
|
||||
let cell = document.createElement("td");
|
||||
cell.colSpan = 2;
|
||||
let h = document.createElement("h" + (2 + (key.level || 1)));
|
||||
h.textContent = key.message? extension.getTranslation(key.message): key.name;
|
||||
cell.appendChild(h);
|
||||
row.appendChild(cell);
|
||||
input.appendChild(row);
|
||||
return;
|
||||
}
|
||||
|
||||
let nameCell = document.createElement("td");
|
||||
nameCell.textContent = setting.display.replaceKeyPattern?
|
||||
key.replace(setting.display.replaceKeyPattern, ""):
|
||||
key;
|
||||
row.appendChild(nameCell);
|
||||
|
||||
let keyType = inputTypes[typeof setting.defaultKeyValue];
|
||||
let keyInput = keyType.input(setting.defaultKeyValue);
|
||||
|
||||
let inputCell = document.createElement("td");
|
||||
inputCell.appendChild(keyInput);
|
||||
row.appendChild(inputCell);
|
||||
|
||||
setting.on(function(){
|
||||
var container = setting.get(url);
|
||||
keyType.updateCallback(
|
||||
keyInput,
|
||||
container && container.hasOwnProperty(key)?
|
||||
container[key]:
|
||||
setting.defaultKeyValue,
|
||||
url
|
||||
);
|
||||
});
|
||||
keyInput.addEventListener("change", function(){
|
||||
var value = keyType.getValue(keyInput);
|
||||
var container = setting.get(url);
|
||||
if (!container){
|
||||
container = setting.defaultValue;
|
||||
}
|
||||
container[key] = value;
|
||||
if (setting.set(container, url)){
|
||||
logging.message("changed setting", setting.name, "(", key, "):", value);
|
||||
}
|
||||
else {
|
||||
container = setting.get(url);
|
||||
keyType.updateCallback(
|
||||
keyInput,
|
||||
container && container.hasOwnProperty(key)?
|
||||
container[key]:
|
||||
setting.defaultKeyValue,
|
||||
url
|
||||
);
|
||||
logging.message("setting", setting.name, "(", key, ") was not changed");
|
||||
}
|
||||
});
|
||||
input.appendChild(row);
|
||||
});
|
||||
input = createKeyInput(setting, url);
|
||||
}
|
||||
|
||||
if (setting.urlSpecific && url === ""){
|
||||
let container = document.createElement("div");
|
||||
container.className = "urlValues " + (setting.getExpand()? "expanded": "collapsed");
|
||||
container.appendChild(input);
|
||||
var collapser = document.createElement("button");
|
||||
collapser.classList.add("collapser");
|
||||
container.appendChild(collapser);
|
||||
collapser.addEventListener("click", function(){
|
||||
setting.setExpand(!setting.getExpand());
|
||||
});
|
||||
setting.onExpandChange(function(value){
|
||||
container.classList[value? "remove": "add"]("collapsed");
|
||||
container.classList[value? "add": "remove"]("expanded");
|
||||
});
|
||||
let urlTable = document.createElement("table");
|
||||
let caption = document.createElement("caption");
|
||||
caption.textContent = extension.getTranslation(setting.urlContainer.name + "_title");
|
||||
urlTable.appendChild(caption);
|
||||
let body = document.createElement("tbody");
|
||||
urlTable.appendChild(body);
|
||||
let foot = document.createElement("tfoot");
|
||||
let footRow = document.createElement("tr");
|
||||
let footCell = document.createElement("td");
|
||||
footCell.colSpan = 3;
|
||||
let newInput = document.createElement("input");
|
||||
newInput.className = "inputURL";
|
||||
newInput.title = extension.getTranslation("inputURL");
|
||||
const addURLSetting = function(){
|
||||
var url = newInput.value.trim();
|
||||
if (url){
|
||||
setting.set(setting.get(url), url);
|
||||
newInput.value = "";
|
||||
newInput.focus();
|
||||
}
|
||||
};
|
||||
newInput.addEventListener("keypress", function(event){
|
||||
if ([10, 13].indexOf(event.keyCode) !== -1){
|
||||
addURLSetting();
|
||||
}
|
||||
});
|
||||
footCell.appendChild(newInput);
|
||||
let footPlus = document.createElement("button");
|
||||
footPlus.classList.add("add");
|
||||
footPlus.textContent = "+";
|
||||
footPlus.addEventListener("click", addURLSetting);
|
||||
footCell.appendChild(footPlus);
|
||||
footRow.appendChild(footCell);
|
||||
foot.appendChild(footRow);
|
||||
urlTable.appendChild(foot);
|
||||
container.appendChild(urlTable);
|
||||
|
||||
setting.urlContainer.on(function({newValue}){
|
||||
body.innerHTML = "";
|
||||
newValue.forEach(function(entry){
|
||||
let row = document.createElement("tr");
|
||||
let urlCell = document.createElement("td");
|
||||
urlCell.classList.add("url");
|
||||
urlCell.addEventListener("click", function(){
|
||||
var input = document.createElement("input");
|
||||
input.classList.add("urlInput");
|
||||
input.style.width = urlCell.clientWidth + "px";
|
||||
input.style.height = urlCell.clientHeight + "px";
|
||||
urlCell.innerHTML = "";
|
||||
urlCell.appendChild(input);
|
||||
input.title = extension.getTranslation("inputURL");
|
||||
input.value = entry.url;
|
||||
input.focus();
|
||||
input.addEventListener("blur", function(){
|
||||
var url = input.value.trim();
|
||||
if (url){
|
||||
entry.url = url;
|
||||
setting.urlContainer.refresh();
|
||||
}
|
||||
urlCell.removeChild(input);
|
||||
urlCell.textContent = entry.url;
|
||||
});
|
||||
});
|
||||
urlCell.textContent = entry.url;
|
||||
row.appendChild(urlCell);
|
||||
let input = createInput(setting, entry.url);
|
||||
type.updateCallback(input, setting.get(entry.url));
|
||||
if (!entry.hasOwnProperty(setting.name)){
|
||||
input.classList.add("notSpecifiedForUrl");
|
||||
}
|
||||
let inputCell = document.createElement("td");
|
||||
inputCell.appendChild(input);
|
||||
row.appendChild(inputCell);
|
||||
let clearCell = document.createElement("td");
|
||||
let clearButton = document.createElement("button");
|
||||
clearButton.className = "reset";
|
||||
clearButton.textContent = "\xD7";
|
||||
clearButton.addEventListener("click", function(){
|
||||
setting.reset(entry.url);
|
||||
});
|
||||
clearCell.appendChild(clearButton);
|
||||
row.appendChild(clearCell);
|
||||
body.appendChild(row);
|
||||
});
|
||||
});
|
||||
return container;
|
||||
return createUrlSpecificInput(setting, input, type);
|
||||
}
|
||||
return input || document.createElement("span");
|
||||
}
|
||||
|
||||
function createButton(setting){
|
||||
var button = document.createElement("button");
|
||||
const button = document.createElement("button");
|
||||
button.textContent = extension.getTranslation(setting.name + "_label");
|
||||
button.addEventListener("click", setting.action);
|
||||
return button;
|
||||
}
|
||||
|
||||
function createInteraction(setting){
|
||||
var c = document.createElement("div");
|
||||
const c = document.createElement("div");
|
||||
c.className = "content";
|
||||
|
||||
var interaction;
|
||||
let interaction;
|
||||
if (setting.action){
|
||||
interaction = createButton(setting);
|
||||
}
|
||||
else if (setting.actions){
|
||||
interaction = document.createElement("span");
|
||||
setting.actions.forEach(function(action){
|
||||
var button = createButton(action);
|
||||
const button = createButton(action);
|
||||
interaction.appendChild(button);
|
||||
});
|
||||
}
|
||||
else if (setting.inputs){
|
||||
interaction = document.createElement("span");
|
||||
setting.inputs.forEach(function(inputSetting){
|
||||
var input = createInput(inputSetting);
|
||||
const input = createInput(inputSetting);
|
||||
input.classList.add("multiple" + setting.inputs.length);
|
||||
interaction.appendChild(input);
|
||||
});
|
||||
|
@ -369,10 +381,10 @@
|
|||
}
|
||||
|
||||
function createHide(setting){
|
||||
var label = document.createElement("label");
|
||||
const label = document.createElement("label");
|
||||
label.className = "content hideContent";
|
||||
label.title = extension.getTranslation("hideSetting");
|
||||
var input = document.createElement("input");
|
||||
const input = document.createElement("input");
|
||||
input.type = "checkbox";
|
||||
input.className = "hide";
|
||||
input.checked = setting.getHide();
|
||||
|
@ -384,26 +396,26 @@
|
|||
});
|
||||
|
||||
label.appendChild(input);
|
||||
var display = document.createElement("span");
|
||||
const display = document.createElement("span");
|
||||
display.className = "display";
|
||||
label.appendChild(display);
|
||||
return label;
|
||||
}
|
||||
|
||||
function createSettingRow(setting){
|
||||
var tr = document.createElement("tr");
|
||||
const tr = document.createElement("tr");
|
||||
tr.className = "settingRow";
|
||||
|
||||
var hide = document.createElement("td");
|
||||
const hide = document.createElement("td");
|
||||
hide.className = "hideColumn";
|
||||
hide.appendChild(createHide(setting));
|
||||
tr.appendChild(hide);
|
||||
|
||||
var left = document.createElement("td");
|
||||
const left = document.createElement("td");
|
||||
left.appendChild(createDescription(setting));
|
||||
tr.appendChild(left);
|
||||
|
||||
var right = document.createElement("td");
|
||||
const right = document.createElement("td");
|
||||
right.appendChild(createInteraction(setting));
|
||||
tr.appendChild(right);
|
||||
|
||||
|
@ -434,7 +446,7 @@
|
|||
displayHiddenDescription.appendChild(createDescription(displayHidden));
|
||||
displayHiddenRow.appendChild(displayHiddenDescription);
|
||||
|
||||
var displayHiddenInteraction = document.createElement("td");
|
||||
const displayHiddenInteraction = document.createElement("td");
|
||||
displayHiddenInteraction.appendChild(createInteraction(displayHidden));
|
||||
displayHiddenRow.appendChild(displayHiddenInteraction);
|
||||
tHead.appendChild(displayHiddenRow);
|
||||
|
|
|
@ -12,93 +12,103 @@
|
|||
const searchParameters = new URLSearchParams(window.location.search);
|
||||
require("./theme").init("presets");
|
||||
|
||||
function buildPresetSettingGui(setting, value){
|
||||
function valueToText(value){
|
||||
switch (typeof value){
|
||||
case "string":
|
||||
return extension.getTranslation(`${setting}_options.${value}`);
|
||||
case "boolean":
|
||||
return value? "\u2713": "\u00D7";
|
||||
default:
|
||||
return value.toString();
|
||||
}
|
||||
}
|
||||
|
||||
const container = document.createElement("li");
|
||||
container.textContent = extension.getTranslation(`${setting}_title`) + ": ";
|
||||
if ((typeof value) === "object"){
|
||||
const urlValues = document.createElement("ul");
|
||||
Object.keys(value).map(function(url){
|
||||
const container = document.createElement("li");
|
||||
container.className = "urlValue";
|
||||
container.textContent = url + ": " +
|
||||
valueToText(value[url]) +
|
||||
" (" + valueToText(settings.get(setting, url)) +")";
|
||||
return container;
|
||||
|
||||
}).forEach(function(node){
|
||||
urlValues.appendChild(node);
|
||||
});
|
||||
container.appendChild(urlValues);
|
||||
}
|
||||
else {
|
||||
container.appendChild(document.createTextNode(
|
||||
`${valueToText(value)} (${valueToText(settings.get(setting))})`
|
||||
));
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
function buildPresetGui(presetName, preset){
|
||||
const container = document.createElement("div");
|
||||
container.className = "preset " + presetName;
|
||||
const title = document.createElement("h1");
|
||||
title.className = "title";
|
||||
title.textContent = extension.getTranslation(`preset_${presetName}_title`);
|
||||
container.appendChild(title);
|
||||
|
||||
const description = document.createElement("div");
|
||||
description.className = "description";
|
||||
description.textContent = extension.getTranslation(`preset_${presetName}_description`);
|
||||
container.appendChild(description);
|
||||
|
||||
const settingsList = document.createElement("ul");
|
||||
settingsList.className = "settings";
|
||||
container.appendChild(settingsList);
|
||||
|
||||
Object.keys(preset).map(function(settingName){
|
||||
return buildPresetSettingGui(settingName, preset[settingName]);
|
||||
}).forEach(function(node){
|
||||
settingsList.appendChild(node);
|
||||
});
|
||||
|
||||
if (settingsList.childNodes.length){
|
||||
const button = document.createElement("button");
|
||||
button.textContent = extension.getTranslation("apply");
|
||||
button.addEventListener("click", function(){
|
||||
Promise.all(Object.keys(preset).map(function(settingName){
|
||||
const value = preset[settingName];
|
||||
if ((typeof value) === "object"){
|
||||
return Promise.all(Object.keys(value).map(function(url){
|
||||
return settings.set(settingName, value[url], url);
|
||||
}));
|
||||
}
|
||||
else {
|
||||
return settings.set(settingName, value);
|
||||
}
|
||||
})).then(function(){
|
||||
window.location.reload();
|
||||
return;
|
||||
}).catch(function(error){
|
||||
logging.warning("Unable to apply preset:", error);
|
||||
});
|
||||
});
|
||||
container.appendChild(button);
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
Promise.all([
|
||||
settings.loaded,
|
||||
fetch("presets.json").then(function(data){
|
||||
return data.json();
|
||||
})
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
]).then(function([settingsLoaded, presets]){
|
||||
Object.keys(presets).map(function(presetName){
|
||||
const preset = presets[presetName];
|
||||
const container = document.createElement("div");
|
||||
container.className = "preset " + presetName;
|
||||
const title = document.createElement("h1");
|
||||
title.className = "title";
|
||||
title.textContent = extension.getTranslation(`preset_${presetName}_title`);
|
||||
container.appendChild(title);
|
||||
|
||||
const description = document.createElement("div");
|
||||
description.className = "description";
|
||||
description.textContent = extension.getTranslation(`preset_${presetName}_description`);
|
||||
container.appendChild(description);
|
||||
|
||||
const settingsList = document.createElement("ul");
|
||||
settingsList.className = "settings";
|
||||
container.appendChild(settingsList);
|
||||
|
||||
Object.keys(preset).map(function(settingName){
|
||||
function valueToText(value){
|
||||
switch (typeof value){
|
||||
case "string":
|
||||
return extension.getTranslation(`${settingName}_options.${value}`);
|
||||
case "boolean":
|
||||
return value? "\u2713": "\u00D7";
|
||||
default:
|
||||
return value.toString();
|
||||
}
|
||||
}
|
||||
|
||||
const value = preset[settingName];
|
||||
const container = document.createElement("li");
|
||||
container.textContent = extension.getTranslation(`${settingName}_title`) + ": ";
|
||||
if ((typeof value) === "object"){
|
||||
const urlValues = document.createElement("ul");
|
||||
Object.keys(value).map(function(url){
|
||||
var container = document.createElement("li");
|
||||
container.className = "urlValue";
|
||||
container.textContent = url + ": " +
|
||||
valueToText(value[url]) +
|
||||
" (" + valueToText(settings.get(settingName, url)) +")";
|
||||
return container;
|
||||
|
||||
}).forEach(function(node){
|
||||
urlValues.appendChild(node);
|
||||
});
|
||||
container.appendChild(urlValues);
|
||||
}
|
||||
else {
|
||||
container.appendChild(document.createTextNode(
|
||||
`${valueToText(value)} (${valueToText(settings.get(settingName))})`
|
||||
));
|
||||
}
|
||||
|
||||
return container;
|
||||
}).forEach(function(node){
|
||||
settingsList.appendChild(node);
|
||||
});
|
||||
|
||||
if (settingsList.childNodes.length){
|
||||
const button = document.createElement("button");
|
||||
button.textContent = extension.getTranslation("apply");
|
||||
button.addEventListener("click", function(){
|
||||
Promise.all(Object.keys(preset).map(function(settingName){
|
||||
const value = preset[settingName];
|
||||
if ((typeof value) === "object"){
|
||||
return Promise.all(Object.keys(value).map(function(url){
|
||||
return settings.set(settingName, value[url], url);
|
||||
}));
|
||||
}
|
||||
else {
|
||||
return settings.set(settingName, value);
|
||||
}
|
||||
})).then(function(){
|
||||
window.location.reload();
|
||||
});
|
||||
});
|
||||
container.appendChild(button);
|
||||
}
|
||||
|
||||
return container;
|
||||
return buildPresetGui(presetName, presets[presetName]);
|
||||
}).forEach(function(node){
|
||||
document.body.appendChild(node);
|
||||
});
|
||||
|
@ -131,6 +141,9 @@
|
|||
document.body.style.fontSize = fontSize + "px";
|
||||
}
|
||||
}
|
||||
return;
|
||||
}).catch(function(error){
|
||||
logging.warning("Unable to setup presets:", error);
|
||||
});
|
||||
|
||||
document.querySelector("head title").textContent = extension.getTranslation("presets_title");
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
(function(){
|
||||
"use strict";
|
||||
|
||||
var scope;
|
||||
let scope;
|
||||
if ((typeof exports) !== "undefined"){
|
||||
scope = exports;
|
||||
}
|
||||
|
@ -84,8 +84,6 @@
|
|||
{mainFlag: "protectScreen", section: "Screen-API"},
|
||||
].forEach(function(api){
|
||||
if (settings.get(api.mainFlag) !== (api.mainFlagDisabledValue || false)){
|
||||
let inSection = false;
|
||||
let anyActive = false;
|
||||
if (getSectionKeys(api.section).every(function(key){
|
||||
return protectedFeaturesValue.hasOwnProperty(key) &&
|
||||
!protectedFeaturesValue[key];
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
require("../lib/theme").init("sanitize");
|
||||
const sanitationRules = require("./sanitationRules");
|
||||
|
||||
var title = document.createElement("h1");
|
||||
const title = document.createElement("h1");
|
||||
title.className = "title";
|
||||
title.textContent = extension.getTranslation("sanitation_title");
|
||||
document.body.appendChild(title);
|
||||
|
||||
var description = document.createElement("div");
|
||||
const description = document.createElement("div");
|
||||
description.className = "description";
|
||||
description.textContent = extension.getTranslation("sanitation_description");
|
||||
document.body.appendChild(description);
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
/* eslint max-lines: off*/
|
||||
(function(){
|
||||
"use strict";
|
||||
var settingsDisplay = [
|
||||
const settingsDisplay = [
|
||||
{
|
||||
name: "general",
|
||||
sections: [
|
||||
|
|
|
@ -11,13 +11,59 @@
|
|||
const searchParameters = new URLSearchParams(window.location.search);
|
||||
|
||||
|
||||
var title = document.createElement("h1");
|
||||
const title = document.createElement("h1");
|
||||
title.className = "title";
|
||||
title.textContent = extension.getTranslation("whitelist_inspection_title");
|
||||
document.body.appendChild(title);
|
||||
|
||||
document.querySelector("head title").textContent = title.textContent;
|
||||
|
||||
|
||||
const whitelistSettings = [
|
||||
{
|
||||
title: extension.getTranslation("whitelist_all_apis"),
|
||||
name: "blockMode",
|
||||
whitelistValue: "allow",
|
||||
protectedValue: "fake"
|
||||
},
|
||||
{
|
||||
title: extension.getTranslation("section_canvas-api"),
|
||||
name: "protectedCanvasPart",
|
||||
whitelistValue: "nothing",
|
||||
protectedValue: "readout"
|
||||
},
|
||||
{
|
||||
title: extension.getTranslation("section_audio-api"),
|
||||
name: "protectAudio",
|
||||
whitelistValue: false,
|
||||
protectedValue: true
|
||||
},
|
||||
{
|
||||
title: extension.getTranslation("section_history-api"),
|
||||
name: "historyLengthThreshold",
|
||||
whitelistValue: 10000,
|
||||
protectedValue: 2
|
||||
},
|
||||
{
|
||||
title: extension.getTranslation("section_window-api"),
|
||||
name: "protectWindow",
|
||||
whitelistValue: false,
|
||||
protectedValue: true
|
||||
},
|
||||
{
|
||||
title: extension.getTranslation("section_DOMRect-api"),
|
||||
name: "protectDOMRect",
|
||||
whitelistValue: false,
|
||||
protectedValue: true
|
||||
},
|
||||
{
|
||||
title: extension.getTranslation("section_navigator-api"),
|
||||
name: "protectNavigator",
|
||||
whitelistValue: false,
|
||||
protectedValue: true
|
||||
},
|
||||
];
|
||||
|
||||
settings.onloaded(function(){
|
||||
const sets = settingContainers.urlContainer.get();
|
||||
|
||||
|
@ -47,51 +93,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
const whitelistSettings = [
|
||||
{
|
||||
title: extension.getTranslation("whitelist_all_apis"),
|
||||
name: "blockMode",
|
||||
whitelistValue: "allow",
|
||||
protectedValue: "fake"
|
||||
},
|
||||
{
|
||||
title: extension.getTranslation("section_canvas-api"),
|
||||
name: "protectedCanvasPart",
|
||||
whitelistValue: "nothing",
|
||||
protectedValue: "readout"
|
||||
},
|
||||
{
|
||||
title: extension.getTranslation("section_audio-api"),
|
||||
name: "protectAudio",
|
||||
whitelistValue: false,
|
||||
protectedValue: true
|
||||
},
|
||||
{
|
||||
title: extension.getTranslation("section_history-api"),
|
||||
name: "historyLengthThreshold",
|
||||
whitelistValue: 10000,
|
||||
protectedValue: 2
|
||||
},
|
||||
{
|
||||
title: extension.getTranslation("section_window-api"),
|
||||
name: "protectWindow",
|
||||
whitelistValue: false,
|
||||
protectedValue: true
|
||||
},
|
||||
{
|
||||
title: extension.getTranslation("section_DOMRect-api"),
|
||||
name: "protectDOMRect",
|
||||
whitelistValue: false,
|
||||
protectedValue: true
|
||||
},
|
||||
{
|
||||
title: extension.getTranslation("section_navigator-api"),
|
||||
name: "protectNavigator",
|
||||
whitelistValue: false,
|
||||
protectedValue: true
|
||||
},
|
||||
];
|
||||
|
||||
const table = document.createElement("table");
|
||||
whitelistSettings.forEach(function(setting){
|
||||
const row = document.createElement("tr");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue