From f5a2c46f245d92e6dfc23c489cf80dbdf9b8a8fc Mon Sep 17 00:00:00 2001 From: kkapsner Date: Tue, 14 Oct 2014 01:06:11 +0200 Subject: [PATCH] Further code cleanup --- lib/main.js | 43 +++++++------------------------------------ 1 file changed, 7 insertions(+), 36 deletions(-) diff --git a/lib/main.js b/lib/main.js index ee23e31..318e80c 100644 --- a/lib/main.js +++ b/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":