|
27 | 27 | if ( arg2 === '{{2}}' ) { arg2 = ''; }
|
28 | 28 | let arg3 = '{{3}}';
|
29 | 29 | if ( arg3 === '{{3}}' ) { arg3 = ''; }
|
30 |
| - const log = arg3 !== '' |
| 30 | + const log = /\blog\b/.test(arg3) |
31 | 31 | ? console.log.bind(console)
|
32 | 32 | : ( ) => { };
|
33 | 33 | const newSyntax = /^[01]?$/.test(arg1) === false;
|
|
77 | 77 | return target.apply(thisArg, args);
|
78 | 78 | }
|
79 | 79 | if ( autoRemoveAfter < 0 ) { return null; }
|
80 |
| - const decoy1 = createDecoy('iframe', 'src', url); |
81 |
| - const decoy2 = createDecoy('object', 'data', url); |
82 |
| - const popup = decoy1.contentWindow || decoy2.contentWindow; |
| 80 | + const decoy = /\bobj\b/.test(arg3) |
| 81 | + ? createDecoy('object', 'data', url) |
| 82 | + : createDecoy('iframe', 'src', url); |
| 83 | + let popup = decoy.contentWindow; |
83 | 84 | Object.defineProperty(popup, 'closed', { value: false });
|
84 |
| - if ( arg3 === '' ) { return popup; } |
85 |
| - return new Proxy(popup, { |
86 |
| - get: function(target, prop) { |
87 |
| - log('window.open / get', prop, '===', target[prop]); |
88 |
| - return target[prop]; |
89 |
| - }, |
90 |
| - set: function(target, prop, value) { |
91 |
| - log('window.open / set', prop, '=', value); |
92 |
| - target[prop] = value; |
93 |
| - }, |
94 |
| - }); |
| 85 | + if ( /\blog\b/.test(arg3) ) { |
| 86 | + popup = new Proxy(popup, { |
| 87 | + get: function(target, prop) { |
| 88 | + log('window.open / get', prop, '===', target[prop]); |
| 89 | + if ( prop === 'closed' ) { return false; } |
| 90 | + return target[prop]; |
| 91 | + }, |
| 92 | + set: function(target, prop, value) { |
| 93 | + log('window.open / set', prop, '=', value); |
| 94 | + target[prop] = value; |
| 95 | + }, |
| 96 | + }); |
| 97 | + } |
| 98 | + return popup; |
95 | 99 | }
|
96 | 100 | });
|
97 | 101 | })();
|
0 commit comments