1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 04:40:20 +01:00

Always protect about:blank

Fixes #652
This commit is contained in:
kkapsner 2023-04-19 14:34:37 +02:00
parent d6916b013e
commit 2c5b00a55d
3 changed files with 26 additions and 6 deletions

View File

@ -52,7 +52,7 @@
logging.message("check url %s for block mode %s", url, blockMode);
switch (url.protocol){
case "about:":
if (url.href === "about:blank"){
if (url.pathname === "blank"){
logging.message("use regular mode on about:blank");
break;
}

View File

@ -6,7 +6,7 @@ Version 1.10:
-
fixes:
-
- always protect about:blank
known issues:
- if a data URL is blocked the page action button does not appear

View File

@ -86,9 +86,28 @@ const iframeAPI = function(){
}
},
{
name: "window.open",
name: "removed iframe",
prepare: async function openWindow(){
const newWindow = window.open("/");
const iframe = document.createElement("iframe");
document.body.appendChild(iframe);
const iframeWindow = iframe.contentWindow;
document.body.removeChild(iframe);
console.log("window of iframe directly after removing", iframeWindow);
return new Promise(function(resolve){
window.setTimeout(function(){
console.log("window of iframe in timeout", iframeWindow);
resolve(iframeWindow);
}, 1000);
});
}
},
];
["/", "about:blank", "about:blank#"].forEach(function(url){
methods.push({
name: "window.open " + url,
prepare: async function openWindow(){
const newWindow = window.open(url);
if (newWindow){
return {
window: newWindow,
@ -106,11 +125,12 @@ const iframeAPI = function(){
});
}
}
}
];
});
});
function getPerformer(callback){
return async function perform(method){
console.log("run iframe method", method.name);
const api = await method.prepare();
callback(api.window, method.name);
api.cleanup();