1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 09:37:12 +02:00

Expand log output of window.open-defuser

This commit is contained in:
Raymond Hill 2020-03-09 10:09:40 -04:00
parent 425c12af54
commit 0f33f2386d
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -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;
},
});