From b76d7c6af6522d0144faa356ee494d58b71218ee Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sun, 8 May 2022 11:22:32 -0400 Subject: [PATCH] Also dispatch `loadend` event in case of match Related issue: - https://github.com/AdguardTeam/Scriptlets/issues/199 --- assets/resources/scriptlets.js | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/assets/resources/scriptlets.js b/assets/resources/scriptlets.js index 002a8cbc9..f7adf4ba1 100644 --- a/assets/resources/scriptlets.js +++ b/assets/resources/scriptlets.js @@ -1253,18 +1253,9 @@ status: { value: 200, writable: false }, statusText: { value: 'OK', writable: false }, }); - if ( this.onreadystatechange !== null ) { - setTimeout(( ) => { - const ev = new Event('readystatechange'); - this.onreadystatechange.call(this, ev); - }, 1); - } - if ( this.onload !== null ) { - setTimeout(( ) => { - const ev = new Event('load'); - this.onload.call(this, ev); - }, 1); - } + this.dispatchEvent(new Event('readystatechange')); + this.dispatchEvent(new Event('load')); + this.dispatchEvent(new Event('loadend')); } }; })(); @@ -1364,9 +1355,11 @@ // https://github.com/uBlockOrigin/uAssets/issues/8 /// alert-buster.js (function() { - window.alert = function(a) { - console.info(a); - }; + window.alert = new Proxy(window.alert, { + apply: function(a) { + console.info(a); + }, + }); })();