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
22
lib/lists.js
22
lib/lists.js
|
@ -6,7 +6,7 @@
|
|||
"use strict";
|
||||
|
||||
|
||||
var scope;
|
||||
let scope;
|
||||
if ((typeof exports) !== "undefined"){
|
||||
scope = exports;
|
||||
}
|
||||
|
@ -14,11 +14,11 @@
|
|||
scope = require.register("./lists", {});
|
||||
}
|
||||
|
||||
var settings = require("./settings");
|
||||
const settings = require("./settings");
|
||||
|
||||
|
||||
function getDomainRegExpList(domainList){
|
||||
var list = domainList
|
||||
const list = domainList
|
||||
.split(",")
|
||||
.map(function(entry){
|
||||
return entry.replace(/^\s+|\s+$/g, "");
|
||||
|
@ -27,8 +27,8 @@
|
|||
return !!entry.length;
|
||||
})
|
||||
.map(function(entry){
|
||||
var regExp;
|
||||
var domain = !!entry.match(/^[A-Za-z0-9_.-]+$/);
|
||||
let regExp;
|
||||
const domain = !!entry.match(/^[A-Za-z0-9_.-]+$/);
|
||||
if (domain){
|
||||
regExp = new RegExp("(?:^|\\.)" + entry.replace(/([\\+*?[^\]$(){}=!|.])/g, "\\$1") + "\\.?$", "i");
|
||||
}
|
||||
|
@ -59,7 +59,7 @@
|
|||
return list;
|
||||
}
|
||||
|
||||
var lists = {
|
||||
const lists = {
|
||||
white: [],
|
||||
sessionWhite: [],
|
||||
"ignore": [],
|
||||
|
@ -81,9 +81,9 @@
|
|||
});
|
||||
|
||||
function updateStackList(value){
|
||||
var list;
|
||||
let list;
|
||||
try {
|
||||
var data = JSON.parse(value);
|
||||
let data = JSON.parse(value);
|
||||
if (!Array.isArray(data)){
|
||||
data = [data];
|
||||
}
|
||||
|
@ -91,7 +91,7 @@
|
|||
return typeof entry === "object" && typeof entry.url === "string";
|
||||
});
|
||||
}
|
||||
catch(e){
|
||||
catch(error){
|
||||
list = [];
|
||||
}
|
||||
list.match = function(stack){
|
||||
|
@ -109,13 +109,13 @@
|
|||
|
||||
scope.get = function getList(type){
|
||||
if (type === "white"){
|
||||
var combined = lists.white.slice().concat(lists.sessionWhite);
|
||||
const combined = lists.white.slice().concat(lists.sessionWhite);
|
||||
return addMatchToList(combined);
|
||||
}
|
||||
return lists[type];
|
||||
};
|
||||
scope.appendTo = function appendToList(type, entry){
|
||||
var oldValue = settings[type + "List"];
|
||||
const oldValue = settings[type + "List"];
|
||||
return settings.set(type + "List", oldValue + (oldValue? ",": "") + entry).then(function(){
|
||||
return updateList(type);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue