Expand log output of window.open-defuser · gorhill/uBlock@0f33f23 (original) (raw)

Original file line number Diff line number Diff line change
@@ -27,6 +27,9 @@
27 27 if ( arg2 === '{{2}}' ) { arg2 = ''; }
28 28 let arg3 = '{{3}}';
29 29 if ( arg3 === '{{3}}' ) { arg3 = ''; }
30 +const log = arg3 !== ''
31 + ? console.log.bind(console)
32 + : ( ) => { };
30 33 const newSyntax = /^[01]?$/.test(arg1) === false;
31 34 let pattern = '';
32 35 let targetResult = true;
@@ -57,6 +60,7 @@
57 60 const rePattern = new RegExp(pattern);
58 61 window.open = new Proxy(window.open, {
59 62 apply: function(target, thisArg, args) {
63 +log('window.open:', ...args);
60 64 const url = args[0];
61 65 if ( rePattern.test(url) !== targetResult ) {
62 66 return target.apply(thisArg, args);
@@ -72,11 +76,11 @@
72 76 if ( arg3 === '' ) { return iframe.contentWindow; }
73 77 return new Proxy(iframe.contentWindow, {
74 78 get: function(target, prop) {
75 -console.log('get', prop, '===', target[prop]);
79 +log('window.open / get', prop, '===', target[prop]);
76 80 return target[prop];
77 81 },
78 82 set: function(target, prop, value) {
79 -console.log('set', prop, '=', value);
83 +log('window.open / set', prop, '=', value);
80 84 target[prop] = value;
81 85 },
82 86 });