Fixed PDF bug + added full RegExp support.

This commit is contained in:
kkapsner 2014-08-10 18:03:58 +02:00
parent 6d0fb5e1f1
commit 124d0a73a5
4 changed files with 24 additions and 7 deletions

Binary file not shown.

View File

@ -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){

View File

@ -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");

View File

@ -9,7 +9,7 @@
"title": "White list",
"description": "Domains where the <canvas>-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}
}