From 0f33f2386d147e4930b402a07418da670524e43f Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Mon, 9 Mar 2020 10:09:40 -0400 Subject: [PATCH] Expand log output of window.open-defuser --- src/web_accessible_resources/window.open-defuser.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/web_accessible_resources/window.open-defuser.js b/src/web_accessible_resources/window.open-defuser.js index 27dd494c5..6a0f24689 100644 --- a/src/web_accessible_resources/window.open-defuser.js +++ b/src/web_accessible_resources/window.open-defuser.js @@ -27,6 +27,9 @@ if ( arg2 === '{{2}}' ) { arg2 = ''; } let arg3 = '{{3}}'; if ( arg3 === '{{3}}' ) { arg3 = ''; } + const log = arg3 !== '' + ? console.log.bind(console) + : ( ) => { }; const newSyntax = /^[01]?$/.test(arg1) === false; let pattern = ''; let targetResult = true; @@ -57,6 +60,7 @@ const rePattern = new RegExp(pattern); window.open = new Proxy(window.open, { apply: function(target, thisArg, args) { + log('window.open:', ...args); const url = args[0]; if ( rePattern.test(url) !== targetResult ) { return target.apply(thisArg, args); @@ -72,11 +76,11 @@ if ( arg3 === '' ) { return iframe.contentWindow; } return new Proxy(iframe.contentWindow, { get: function(target, prop) { - console.log('get', prop, '===', target[prop]); + log('window.open / get', prop, '===', target[prop]); return target[prop]; }, set: function(target, prop, value) { - console.log('set', prop, '=', value); + log('window.open / set', prop, '=', value); target[prop] = value; }, });