diff --git a/canvasblocker.xpi b/canvasblocker.xpi index 6b19818..821854c 100644 Binary files a/canvasblocker.xpi and b/canvasblocker.xpi differ diff --git a/data/inject.js b/data/inject.js index 02ba040..0c4cd8b 100644 --- a/data/inject.js +++ b/data/inject.js @@ -4,9 +4,9 @@ var askFunctionName = Math.random().toString(16); function checkPDF(blocking){ if (unsafeWindow.document.contentType.match(/\/pdf$/i)){ self.port.emit("isPDF", blocking); - return false; + return true; } - return true; + return false; } function block(force){ diff --git a/lib/main.js b/lib/main.js index 11ead3e..a29b4d6 100644 --- a/lib/main.js +++ b/lib/main.js @@ -8,7 +8,24 @@ function getDomainRegExpList(domainList){ return !!entry.length; }) .map(function(entry){ - return new RegExp("(?:^|\\.)" + entry.replace(/([\\\+\*\?\[\^\]\$\(\)\{\}\=\!\|\.])/g, "\\$1") + "\\.?$", "i"); + var regExp; + var domain = !!entry.match(/^[\w.]+$/); + if (domain){ + regExp = new RegExp("(?:^|\\.)" + entry.replace(/([\\\+\*\?\[\^\]\$\(\)\{\}\=\!\|\.])/g, "\\$1") + "\\.?$", "i") + } + else { + regExp = new RegExp(entry, "i"); + } + return { + match: function(url){ + if (domain){ + return url.hostname.match(regExp); + } + else { + return url.href.match(regExp); + } + } + }; }); } @@ -52,14 +69,14 @@ function checkWorker(worker){ else { var url = new URL(worker.url); var inBlackList = blackList.some(function(entry){ - return url.hostname.match(entry); + return entry.match(url); }); if (inBlackList){ worker.port.emit("block"); } else { var inWhiteList = whiteList.some(function(entry){ - return url.hostname.match(entry); + return entry.match(url); }); if (inWhiteList){ worker.port.emit("unblock"); diff --git a/package.json b/package.json index 3f05939..a3b5999 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "title": "White list", "description": "Domains where the -API should not be blocked. To add multiple domains seperate them by comma.", "type": "string", - "value": "kkapsner.de" + "value": "kkapsner.de,^https?://(\\\\w+\\\\.)*google.[a-z]+/maps" }, { "name": "blockAll", @@ -42,6 +42,6 @@ ], "author": "Korbinian Kapsner", "license": "MPL 2.0", - "version": "0.1", + "version": "0.1.1", "permissions": {"private-browsing": true} }