Open mrtnetwork opened 3 months ago
Summary: The user is experiencing an issue where the chrome
and browser
objects are undefined in a Dart content script running in a Firefox extension, while the same code works in Chrome. The user has confirmed that a simple JavaScript content script can access these objects in Firefox.
something like this in js code solved my problem
main() {
if(self.browser === undefined){
self.browser = browser
}
.....
}
Maybe this is a question of privilege and content scripts can access the API while the compiled Dart code can not?
Hello everyone,
I'm currently working on a browser extension using Flutter and have run into an issue with Firefox. When I build my Dart file for the content script, both the browser and chrome objects are undefined in the content script. However, when I load a simple JavaScript file as the content script, these objects are available as expected.
Interestingly, the same setup works perfectly in Chrome—both the Dart content script and the JavaScript content script can access the chrome object without any issues.
Has anyone else encountered this problem, or does anyone have any suggestions for resolving it? Any help would be greatly appreciated!
Thanks in advance!
compile
doctor -v