Created
April 27, 2026 19:38
-
-
Save cgarrovillo/be14c37a29a97c8366608effc071656f to your computer and use it in GitHub Desktop.
Stalling Accept.JS Script Loads
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (() => { | |
| if (window.__acceptStalled) { | |
| console.warn("[stall] already installed"); | |
| return; | |
| } | |
| const ACCEPT_RE = /authorize\.net\/v1\/Accept\.js/i; | |
| const origAdd = EventTarget.prototype.addEventListener; | |
| const stalled = []; | |
| EventTarget.prototype.addEventListener = function (type, listener, opts) { | |
| const isAcceptScript = | |
| this instanceof HTMLScriptElement && | |
| typeof this.src === "string" && | |
| ACCEPT_RE.test(this.src); | |
| if (isAcceptScript && (type === "load" || type === "error")) { | |
| stalled.push({ target: this, type, listener }); | |
| console.warn("[stall] swallowed Accept.js", type, "listener for", this.src); | |
| return; | |
| } | |
| return origAdd.call(this, type, listener, opts); | |
| }; | |
| window.__acceptStalled = true; | |
| window.__stalledAccept = stalled; | |
| window.__releaseAccept = () => { | |
| EventTarget.prototype.addEventListener = origAdd; | |
| console.warn("[stall] releasing", stalled.length, "load listeners"); | |
| stalled.forEach(({ listener, type }) => { | |
| if (type === "load") { | |
| try { listener(new Event("load")); } catch (e) { console.error(e); } | |
| } | |
| }); | |
| stalled.length = 0; | |
| delete window.__acceptStalled; | |
| delete window.__releaseAccept; | |
| }; | |
| console.warn( | |
| "[stall] Accept.js load is now stalled. Click Purchase to repro. " + | |
| "Run window.__releaseAccept() when you're done observing." | |
| ); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment