@@ -1281,30 +1281,32 @@ function addEventListenerDefuser(
1281
1281
}
1282
1282
return matchesBoth ;
1283
1283
} ;
1284
- runAt ( ( ) => {
1285
- proxyApplyFn ( 'EventTarget.prototype.addEventListener' , function ( context ) {
1286
- const { callArgs, thisArg } = context ;
1287
- let t , h ;
1288
- try {
1289
- t = String ( callArgs [ 0 ] ) ;
1290
- if ( typeof callArgs [ 1 ] === 'function' ) {
1291
- h = String ( safe . Function_toString ( callArgs [ 1 ] ) ) ;
1292
- } else if ( typeof callArgs [ 1 ] === 'object' && callArgs [ 1 ] !== null ) {
1293
- if ( typeof callArgs [ 1 ] . handleEvent === 'function' ) {
1294
- h = String ( safe . Function_toString ( callArgs [ 1 ] . handleEvent ) ) ;
1295
- }
1296
- } else {
1297
- h = String ( callArgs [ 1 ] ) ;
1284
+ const proxyFn = function ( context ) {
1285
+ const { callArgs, thisArg } = context ;
1286
+ let t , h ;
1287
+ try {
1288
+ t = String ( callArgs [ 0 ] ) ;
1289
+ if ( typeof callArgs [ 1 ] === 'function' ) {
1290
+ h = String ( safe . Function_toString ( callArgs [ 1 ] ) ) ;
1291
+ } else if ( typeof callArgs [ 1 ] === 'object' && callArgs [ 1 ] !== null ) {
1292
+ if ( typeof callArgs [ 1 ] . handleEvent === 'function' ) {
1293
+ h = String ( safe . Function_toString ( callArgs [ 1 ] . handleEvent ) ) ;
1298
1294
}
1299
- } catch {
1300
- }
1301
- if ( type === '' && pattern === '' ) {
1302
- safe . uboLog ( logPrefix , `Called: ${ t } \n${ h } \n${ elementDetails ( thisArg ) } ` ) ;
1303
- } else if ( shouldPrevent ( thisArg , t , h ) ) {
1304
- return safe . uboLog ( logPrefix , `Prevented: ${ t } \n${ h } \n${ elementDetails ( thisArg ) } ` ) ;
1295
+ } else {
1296
+ h = String ( callArgs [ 1 ] ) ;
1305
1297
}
1306
- return context . reflect ( ) ;
1307
- } ) ;
1298
+ } catch {
1299
+ }
1300
+ if ( type === '' && pattern === '' ) {
1301
+ safe . uboLog ( logPrefix , `Called: ${ t } \n${ h } \n${ elementDetails ( thisArg ) } ` ) ;
1302
+ } else if ( shouldPrevent ( thisArg , t , h ) ) {
1303
+ return safe . uboLog ( logPrefix , `Prevented: ${ t } \n${ h } \n${ elementDetails ( thisArg ) } ` ) ;
1304
+ }
1305
+ return context . reflect ( ) ;
1306
+ } ;
1307
+ runAt ( ( ) => {
1308
+ proxyApplyFn ( 'EventTarget.prototype.addEventListener' , proxyFn ) ;
1309
+ proxyApplyFn ( 'document.addEventListener' , proxyFn ) ;
1308
1310
} , extraArgs . runAt ) ;
1309
1311
}
1310
1312
0 commit comments