mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 21:00:23 +01:00
Convenience preset did not work properly
This commit is contained in:
parent
ee87773ce2
commit
872e633025
@ -40,6 +40,7 @@
|
|||||||
let newEntry = {url};
|
let newEntry = {url};
|
||||||
newEntry[name] = value;
|
newEntry[name] = value;
|
||||||
urlContainerValue.push(newEntry);
|
urlContainerValue.push(newEntry);
|
||||||
|
initializeUrlSetting(newEntry);
|
||||||
matching = [newEntry];
|
matching = [newEntry];
|
||||||
}
|
}
|
||||||
matching[0][name] = value;
|
matching[0][name] = value;
|
||||||
@ -164,51 +165,53 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function initializeUrlSetting(urlSetting){
|
||||||
|
let regExp;
|
||||||
|
const domain = !!urlSetting.url.match(/^[A-Za-z0-9_.-]+$/);
|
||||||
|
if (domain){
|
||||||
|
regExp = new RegExp(
|
||||||
|
"(?:^|\\.)" + urlSetting.url.replace(/([\\+*?[^\]$(){}=!|.])/g, "\\$1") + "\\.?$",
|
||||||
|
"i"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
regExp = new RegExp(urlSetting.url, "i");
|
||||||
|
}
|
||||||
|
const match = function(url){
|
||||||
|
if (!url){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (
|
||||||
|
url instanceof String ||
|
||||||
|
(typeof url) === "string"
|
||||||
|
){
|
||||||
|
return url === urlSetting.url;
|
||||||
|
}
|
||||||
|
else if (domain){
|
||||||
|
return (url.hostname || "").match(regExp);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return url.href.match(regExp);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Object.defineProperty(
|
||||||
|
urlSetting,
|
||||||
|
"match",
|
||||||
|
{
|
||||||
|
enumerable: false,
|
||||||
|
writable: true,
|
||||||
|
configurable: true,
|
||||||
|
value: match
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
scope.initializeUrlContainer = function(eventHandler){
|
scope.initializeUrlContainer = function(eventHandler){
|
||||||
if (!scope.urlContainer){
|
if (!scope.urlContainer){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
scope.urlContainer.on(function({newValue, oldValue}){
|
scope.urlContainer.on(function({newValue, oldValue}){
|
||||||
newValue.forEach(function(urlSetting){
|
newValue.forEach(initializeUrlSetting);
|
||||||
let regExp;
|
|
||||||
const domain = !!urlSetting.url.match(/^[A-Za-z0-9_.-]+$/);
|
|
||||||
if (domain){
|
|
||||||
regExp = new RegExp(
|
|
||||||
"(?:^|\\.)" + urlSetting.url.replace(/([\\+*?[^\]$(){}=!|.])/g, "\\$1") + "\\.?$",
|
|
||||||
"i"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
regExp = new RegExp(urlSetting.url, "i");
|
|
||||||
}
|
|
||||||
const match = function(url){
|
|
||||||
if (!url){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (
|
|
||||||
url instanceof String ||
|
|
||||||
(typeof url) === "string"
|
|
||||||
){
|
|
||||||
return url === urlSetting.url;
|
|
||||||
}
|
|
||||||
else if (domain){
|
|
||||||
return (url.hostname || "").match(regExp);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return url.href.match(regExp);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Object.defineProperty(
|
|
||||||
urlSetting,
|
|
||||||
"match",
|
|
||||||
{
|
|
||||||
enumerable: false,
|
|
||||||
writable: true,
|
|
||||||
configurable: true,
|
|
||||||
value: match
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
const newUrls = newValue.map(function(entry){return entry.url;});
|
const newUrls = newValue.map(function(entry){return entry.url;});
|
||||||
const oldUrls = oldValue.map(function(entry){return entry.url;});
|
const oldUrls = oldValue.map(function(entry){return entry.url;});
|
||||||
|
@ -8,6 +8,7 @@ Version 1.6:
|
|||||||
|
|
||||||
fixes:
|
fixes:
|
||||||
- fix message canvasBlocker-unload
|
- fix message canvasBlocker-unload
|
||||||
|
- convenience preset did not work properly
|
||||||
|
|
||||||
known issues:
|
known issues:
|
||||||
- if a data URL is blocked the page action button does not appear
|
- if a data URL is blocked the page action button does not appear
|
||||||
|
Loading…
x
Reference in New Issue
Block a user