duckduckgo / tracker-surrogates

💉 Surrogates are small scripts that our apps and extensions serve in place of trackers that cause site breakage when blocked.
Other
20 stars 11 forks source link

Harden _Q.push wrapper in the amzn_apstag.js shim #41

Closed kzar closed 6 months ago

kzar commented 6 months ago

Apstag calls are queued onto the window.apstag._Q array and are then called when the Apstag script is ready. The shim expects each queued call to be an array containing the API method name prefix and arguments, e.g.

["f", {slots: [...], timeout: 3000}, () => { ... }]

I noticed in practice however, some calls are queued differently, with a queued call looking something like this instead:

[["f", Arguments([{slots: [...], timeout: 3000}, () => { ... }])]]

Since the original script handles that, the shim needs to as well. Let's try our best here, without changing too much and risking further breakage.