execute method

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.

Implementation

Future<List<InjectionResult>> execute(UserScriptInjection injection) async {
  var $res = await $js.chrome.userScripts.execute(injection.toJS).toDart;
  return $res.toDart
      .cast<$js.InjectionResult>()
      .map((e) => InjectionResult.fromJS(e))
      .toList();
}