fregante / content-scripts-register-polyfill

WebExtensions: Polyfill for browser.contentScripts.register() for Chrome.
https://npm.im/content-scripts-register-polyfill
MIT License
25 stars 6 forks source link

Restore support for multiple registrations on the same host #60

Closed laosb closed 2 years ago

laosb commented 2 years ago

In wasPreviouslyLoaded, the arg is directly used as a object key so inexplict toString is used to transform arg into a string. Very unfortunately on the call site the arg passed in is { css, js }, which means no matter whatever value css or js is, it always translate to [object Object].

This bug makes it impossible to register multiple scripts for a tab.

This is probably not the best fix, as css or js can be very huge, thus JSON.stringify can spend a lot of time doing its job.

Sorry for submitting PR w/o discussion. I used this solution to fix my near-production product, so I think I might just as well send it here.

fregante commented 2 years ago

Ahhh sorry and thank you for the PR. I broke this 2 weeks ago in https://github.com/fregante/content-scripts-register-polyfill/pull/57. I'm publishing a new version now