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

document.write and document.writeln protection broke pages

Fixes #365
This commit is contained in:
kkapsner 2019-06-11 23:09:13 +02:00
parent 27ddc8a683
commit 1737344480
3 changed files with 34 additions and 25 deletions

View File

@ -159,8 +159,9 @@
"write"
);
const documentWrite = documentWriteDescriptor.value;
documentWriteDescriptor.value = exportFunction(function write(str){
str = "" + str;
documentWriteDescriptor.value = exportFunction(function write(markup){
for (let i = 0, l = arguments.length; i < l; i += 1){
const str = "" + arguments[i];
// weird problem with waterfox and google docs
const parts = (
str.match(/^\s*<!doctype/i) &&
@ -175,6 +176,7 @@
observe();
}
}
}
}, window);
Object.defineProperty(wrappedWindow.HTMLDocument.prototype, "write", documentWriteDescriptor);
@ -186,10 +188,11 @@
"writeln"
);
const documentWriteln = documentWritelnDescriptor.value;
documentWritelnDescriptor.value = exportFunction(function writeln(str){
str = "" + str;
documentWritelnDescriptor.value = exportFunction(function writeln(markup){
for (let i = 0, l = arguments.length; i < l; i += 1){
const str = "" + arguments[i];
const parts = str.split(/(?=<)/);
const length = parts.length - 1;
const length = parts.length;
const scripts = window.document.getElementsByTagName("script");
for (let i = 0; i < length; i += 1){
documentWrite.call(this, parts[i]);
@ -198,7 +201,8 @@
observe();
}
}
documentWriteln.call(this, parts[length]);
}
documentWriteln.call(this, "");
}, window);
Object.defineProperty(wrappedWindow.HTMLDocument.prototype, "writeln", documentWritelnDescriptor);
};

View File

@ -8,6 +8,7 @@ Version 0.5.11:
fixes:
- improved protection of (i)frame properties
- document.write and document.writeln protection broke pages
known issues:
- if a data URL is blocked the page action button does not appear

View File

@ -13,6 +13,10 @@
{
"version": "0.5.11Alpha20190611",
"update_link": "https://canvasblocker.kkapsner.de/versions/canvasblocker_beta-0.5.11Alpha20190611-an+fx.xpi"
},
{
"version": "0.5.11Alpha20190612",
"update_link": "https://canvasblocker.kkapsner.de/versions/canvasblocker_beta-0.5.11Alpha20190612-an+fx.xpi"
}
]
}