mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-04 20:46:39 +02:00
Big linting
This commit is contained in:
parent
b5e6d049ce
commit
aef6bd3d59
58 changed files with 2074 additions and 1856 deletions
|
@ -4,7 +4,7 @@
|
|||
(function(require){
|
||||
"use strict";
|
||||
|
||||
var scope;
|
||||
let scope;
|
||||
if ((typeof exports) !== "undefined"){
|
||||
scope = exports;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@
|
|||
if (!Array.isArray(newValue)){
|
||||
return "wrongType";
|
||||
}
|
||||
var entriesInvalid = newValue.reduce(function(v, entry){
|
||||
const entriesInvalid = newValue.reduce(function(v, entry){
|
||||
v = v || settingDefinition.entries.reduce(function(v, entryDefinition){
|
||||
return v || isDefinitionInvalid(entryDefinition, entry[entryDefinition.name]);
|
||||
}, false);
|
||||
|
@ -74,7 +74,7 @@
|
|||
else if (settingDefinition.urlSpecific){
|
||||
return function getValue(url){
|
||||
if (url){
|
||||
var match = settingContainers.getUrlValueContainer(settingDefinition.name, url);
|
||||
const match = settingContainers.getUrlValueContainer(settingDefinition.name, url);
|
||||
if (match){
|
||||
return match[settingDefinition.name];
|
||||
}
|
||||
|
@ -105,13 +105,13 @@
|
|||
function createSetter(settingDefinition){
|
||||
if (settingDefinition.dynamic){
|
||||
return function setValue(newValue){
|
||||
settingDefinition.setter(scope);
|
||||
settingDefinition.setter(scope, newValue);
|
||||
};
|
||||
}
|
||||
else {
|
||||
const name = settingDefinition.name;
|
||||
const isValid = function isValid(newValue){
|
||||
var invalid = settingDefinition.invalid(newValue);
|
||||
const invalid = settingDefinition.invalid(newValue);
|
||||
if (invalid){
|
||||
if (invalid === "fixed"){
|
||||
logging.warning("Trying to set the fixed setting", name, ":", newValue);
|
||||
|
@ -133,13 +133,14 @@
|
|||
logging.verbose("Trying to store new value for %s", name, newValue);
|
||||
settings[name] = newValue;
|
||||
if (!settingDefinition.transient){
|
||||
var storeObject = {};
|
||||
const storeObject = {};
|
||||
storeObject[name] = newValue;
|
||||
var promise = browser.storage.local.set(storeObject);
|
||||
const promise = browser.storage.local.set(storeObject);
|
||||
promise.then(function(){
|
||||
logging.verbose("New value stored for %s:", name, newValue);
|
||||
}, function(err){
|
||||
logging.error("Unable to store new value for %s:", name, newValue, err);
|
||||
return;
|
||||
}).catch(function(error){
|
||||
logging.error("Unable to store new value for %s:", name, newValue, error);
|
||||
});
|
||||
return promise;
|
||||
}
|
||||
|
@ -227,7 +228,7 @@
|
|||
};
|
||||
|
||||
settingDefinitions.forEach(function(settingDefinition){
|
||||
var name = settingDefinition.name;
|
||||
const name = settingDefinition.name;
|
||||
definitionsByName[name] = settingDefinition;
|
||||
if (typeof settingDefinition.defaultValue === "function"){
|
||||
settingDefinition.defaultValue = settingDefinition.defaultValue();
|
||||
|
@ -282,7 +283,7 @@
|
|||
});
|
||||
|
||||
scope.getDefinition = function(name){
|
||||
var foundDefinition = definitionsByName[name];
|
||||
const foundDefinition = definitionsByName[name];
|
||||
if (foundDefinition){
|
||||
return Object.create(foundDefinition);
|
||||
}
|
||||
|
@ -300,7 +301,7 @@
|
|||
};
|
||||
|
||||
scope.set = function(name, ...args){
|
||||
var foundDefinition = definitionsByName[name];
|
||||
const foundDefinition = definitionsByName[name];
|
||||
if (foundDefinition){
|
||||
return foundDefinition.set(...args);
|
||||
}
|
||||
|
@ -309,7 +310,7 @@
|
|||
}
|
||||
};
|
||||
scope.get = function(name, ...args){
|
||||
var foundDefinition = definitionsByName[name];
|
||||
const foundDefinition = definitionsByName[name];
|
||||
if (foundDefinition){
|
||||
return foundDefinition.get(...args);
|
||||
}
|
||||
|
@ -328,9 +329,9 @@
|
|||
|
||||
const resetSymbol = Symbol("reset");
|
||||
function changeValue(name, newValue){
|
||||
var settingDefinition = scope.getDefinition(name);
|
||||
const settingDefinition = scope.getDefinition(name);
|
||||
if (settingDefinition){
|
||||
var oldValue = settings[name];
|
||||
const oldValue = settings[name];
|
||||
if (newValue === resetSymbol){
|
||||
newValue = getDefaultValue(settingDefinition);
|
||||
}
|
||||
|
@ -355,7 +356,7 @@
|
|||
browser.storage.onChanged.addListener(function(changes, area){
|
||||
if (area === "local"){
|
||||
logging.notice("settings changed", changes);
|
||||
var delayedChange = [];
|
||||
const delayedChange = [];
|
||||
Object.entries(changes).forEach(function(entry){
|
||||
const [name, change] = entry;
|
||||
if (settingContainers.urlContainer && name === settingContainers.urlContainer.name){
|
||||
|
@ -407,7 +408,7 @@
|
|||
{settings, logging, changeValue, urlContainer: settingContainers.urlContainer}
|
||||
);
|
||||
}
|
||||
var delayedChange = [];
|
||||
const delayedChange = [];
|
||||
Object.entries(storage).forEach(function(entry){
|
||||
const [name, value] = entry;
|
||||
if (settingContainers.urlContainer && name === settingContainers.urlContainer.name){
|
||||
|
@ -451,8 +452,8 @@
|
|||
xhr.send();
|
||||
xhr = null;
|
||||
}
|
||||
catch (e){
|
||||
logging.verbose("Error in XHR:", e);
|
||||
catch (error){
|
||||
logging.verbose("Error in XHR:", error);
|
||||
}
|
||||
logging.message("settings still default?", settings.isStillDefault);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue