1
0
Fork 0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-07-04 20:46:39 +02:00

Adjusted protection for document.write and document.writeln

Fixes #356
This commit is contained in:
kkapsner 2019-05-29 14:22:52 +02:00
parent 1e8553dd01
commit 34f8050fb7
4 changed files with 23 additions and 3 deletions

View file

@ -148,7 +148,12 @@
);
const documentWrite = documentWriteDescriptor.value;
documentWriteDescriptor.value = exportFunction(function write(str){
const parts = str.split(/(?=<)/);
str = "" + str;
// weird problem with waterfox and google docs
const parts = (
str.match(/^\s*<!doctype/i) &&
!str.match(/frame/i)
)? [str]: str.split(/(?=<)/);
const length = parts.length;
const scripts = window.document.getElementsByTagName("script");
for (let i = 0; i < length; i += 1){
@ -170,6 +175,7 @@
);
const documentWriteln = documentWritelnDescriptor.value;
documentWritelnDescriptor.value = exportFunction(function writeln(str){
str = "" + str;
const parts = str.split(/(?=<)/);
const length = parts.length - 1;
const scripts = window.document.getElementsByTagName("script");