executeScript method

Future<List<InjectionResult>> executeScript(
  1. ScriptInjection injection
)

Injects a script into a target context. By default, the script will be run at document_idle, or immediately if the page has already loaded. If the injectImmediately property is set, the script will inject without waiting, even if the page has not finished loading. 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. |Returns|: Returns a Promise which resolves 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 $js.chrome.scripting.executeScript(injection.toJS).toDart;
  return $res.toDart
      .cast<$js.InjectionResult>()
      .map((e) => InjectionResult.fromJS(e))
      .toList();
}