Is it possible to use dart for chrome extension content scripts? The following does not seem to call anything in main()
import 'dart:html';
import 'package:js/js.dart' as js;
void main() {
js.context.alert('Hello from Dart via JavaScript');
window.console.log("START!!!");
window.alert("alert");
}
manifest.json...
"content_scripts": [
{
"matches": [
"http://docs.google.com/*",
"https://docs.google.com/*"
],
"js": [
"packages/browser/dart.js",
"packages/browser/interop.js",
"packages/js/dart_interop.js",
"out.js"
],
"run_at" : "document_idle",
"all_frames" : false
}
],
I'm not familiar with chrome extension content scripts myself, but from looking at the docs, it seems like they operate in a more restricted world then regular browser scripts. From the docs, they can't:
It could be that the dart2js output is running afoul of one of these rules. You can try compiling the dart code with the --disallow-unsafe-eval option. It's used for scripts that need to run in an CSP environment. You might also look in devtools to see if there are any helpful errors -