awesome-webextension / webpack-target-webextension

WebExtension Target for Webpack 5. Supports code-splitting and HMR.
MIT License
46 stars 5 forks source link

It doesn't work if the page contains an element with `id="browser"` #27

Closed fregante closed 2 years ago

fregante commented 2 years ago

Elements with ids will automatically become globals so this check is truthy even when it shouldn't be:

https://github.com/awesome-webextension/webpack-target-webextension/blob/5272fd5070f7d79929f0440d511ab450e620c36b/lib/webpack5/RuntimeModules/ChunkLoaderFallback.js#L21

Gotta love Netscape.

Screen Shot 6

Test URL: https://ghosttext.fregante.com/

Suggested fix: use this or its globalThis-less equivalent:

const isModern = typeof globalThis.browser?.runtime?.getURL === 'function'
fregante commented 2 years ago

This check also fails with a simple <script>var browser = "<?php get_browser() ?>"</script> in the <head>