mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 12:50:36 +01:00
Further code cleanup
This commit is contained in:
parent
feb16823c1
commit
f5a2c46f24
43
lib/main.js
43
lib/main.js
@ -1,5 +1,6 @@
|
||||
/* global console */
|
||||
(function(){
|
||||
"use strict";
|
||||
"use strict";
|
||||
|
||||
function getDomainRegExpList(domainList){
|
||||
var list = domainList
|
||||
@ -14,7 +15,7 @@
|
||||
var regExp;
|
||||
var domain = !!entry.match(/^[\w.]+$/);
|
||||
if (domain){
|
||||
regExp = new RegExp("(?:^|\\.)" + entry.replace(/([\\\+\*\?\[\^\]\$\(\)\{\}\=\!\|\.])/g, "\\$1") + "\\.?$", "i")
|
||||
regExp = new RegExp("(?:^|\\.)" + entry.replace(/([\\\+\*\?\[\^\]\$\(\)\{\}\=\!\|\.])/g, "\\$1") + "\\.?$", "i");
|
||||
}
|
||||
else {
|
||||
regExp = new RegExp(entry, "i");
|
||||
@ -34,8 +35,8 @@
|
||||
list.match = function(url){
|
||||
return this.some(function(entry){
|
||||
return entry.match(url);
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return list;
|
||||
}
|
||||
@ -45,7 +46,7 @@
|
||||
var array = require("sdk/util/array");
|
||||
var preferences = require("sdk/simple-prefs");
|
||||
var prefs = preferences.prefs;
|
||||
var {URL} = require("sdk/url");
|
||||
var URL = require("sdk/url").URL;
|
||||
var _ = require("sdk/l10n").get;
|
||||
|
||||
// preferences
|
||||
@ -88,38 +89,8 @@
|
||||
}
|
||||
break;
|
||||
case "ask":
|
||||
if (whiteList.match(url)){
|
||||
mode = "unblock";
|
||||
}
|
||||
else if (blackList.match(url)){
|
||||
mode = "block";
|
||||
}
|
||||
else {
|
||||
mode = "ask";
|
||||
}
|
||||
break;
|
||||
case "blockReadout":
|
||||
if (whiteList.match(url)){
|
||||
mode = "unblock";
|
||||
}
|
||||
else if (blackList.match(url)){
|
||||
mode = "block";
|
||||
}
|
||||
else {
|
||||
mode = "blockReadout";
|
||||
}
|
||||
break;
|
||||
case "fakeReadout":
|
||||
if (whiteList.match(url)){
|
||||
mode = "unblock";
|
||||
}
|
||||
else if (blackList.match(url)){
|
||||
mode = "block";
|
||||
}
|
||||
else {
|
||||
mode = "fakeReadout";
|
||||
}
|
||||
break;
|
||||
case "askReadout":
|
||||
if (whiteList.match(url)){
|
||||
mode = "unblock";
|
||||
@ -128,7 +99,7 @@
|
||||
mode = "block";
|
||||
}
|
||||
else {
|
||||
mode = "askReadout";
|
||||
mode = prefs.blockMode;
|
||||
}
|
||||
break;
|
||||
case "blockOnlyBlackList":
|
||||
|
Loading…
x
Reference in New Issue
Block a user