-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
executeScript with function #7
Comments
The function to pass to this API is a bit special. This is an "InjectedFunction" and it needs to be serializable. Maybe we could come up with a way to create a JS function from a string: func: 'function() { console.log("test"); }'.toJSFunction At this point, your best alternative maybe to inject a file: await chrome.scripting.executeScript(ScriptInjection(
target: InjectionTarget(tabId: currentTab.id!), files: ['script.dart.js'])); |
It would be great if it could be from a string |
I tried something like that: @staticInterop
@JS('Function')
class FunctionFromCode {
external factory FunctionFromCode(String code);
}
void main() {
await chrome.scripting.executeScript(ScriptInjection(
target: InjectionTarget(tabId: currentTab.id!),
func: FunctionFromCode('console.log("Hello from dart script");').toJS));
} but it doesn't work because of Content Security Policy of the chrome extension |
@xvrh Hey, any updates about this? |
@dom3lek no news. Feel free to have a look and share your results. thanks |
This is not a solution... but Dart's port of |
Any examples of how to correctly use the executeScript method?
This doesn't seem to output anything to the browser devtools console.
The text was updated successfully, but these errors were encountered: