Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to use this polyfill from a web page that needs to send messages to an extension? #389

Closed
BlindDespair opened this issue Jun 29, 2022 · 1 comment

Comments

@BlindDespair
Copy link

We need to request some info from our extesnion on our website and want to make it cross-browser, but when I tried using this polyfill to make the messaging work in all supported browsers and it works great for communication inside the extension. But when I try to use it on the web page I get Uncaught Error: This script should only be loaded in a browser extension. and that's really because making this to work in all browsers will be rather difficult.
I saw there's a typeof globalThis != "object" || typeof chrome != "object" || !chrome || !chrome.runtime || !chrome.runtime.id check and the only check web page does not pass is the chrome.runtime.id obviously because it's not an extension. But can I ask what is the motivation for not allowing this polyfill work on web pages as well?
Is there a way to make this work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants