executeScript method
Injects a script into a target context. The script will be run at
document_idle
. If the script evaluates to a promise,
the browser will wait for the promise to settle and return the
resulting value.
|injection|: The details of the script which to inject.
|callback|: Invoked upon completion of the injection. The resulting
array contains the result of execution for each frame where the
injection succeeded.
Implementation
Future<List<InjectionResult>> executeScript(ScriptInjection injection) async {
var $res = await promiseToFuture<JSArray>(
$js.chrome.scripting.executeScript(injection.toJS));
return $res.toDart
.cast<$js.InjectionResult>()
.map((e) => InjectionResult.fromJS(e))
.toList();
}