| 1 | /** |
| 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | * |
| 4 | * This source code is licensed under the MIT license found in the |
| 5 | * LICENSE file in the root directory of this source tree. |
| 6 | * |
| 7 | * @flow |
| 8 | */ |
| 9 | /* global chrome */ |
| 10 | |
| 11 | export function executeScriptInIsolatedWorld({ |
| 12 | target, |
| 13 | files, |
| 14 | }: { |
| 15 | files: any, |
| 16 | target: any, |
| 17 | }): Promise<void> { |
| 18 | return chrome.scripting.executeScript({ |
| 19 | target, |
| 20 | files, |
| 21 | world: chrome.scripting.ExecutionWorld.ISOLATED, |
| 22 | }); |
| 23 | } |
| 24 | |
| 25 | export function executeScriptInMainWorld({ |
| 26 | target, |
| 27 | files, |
| 28 | injectImmediately, |
| 29 | }: { |
| 30 | files: any, |
| 31 | target: any, |
| 32 | // It's nice to have this required to make active choices. |
| 33 | injectImmediately: boolean, |
| 34 | }): Promise<void> { |
| 35 | return chrome.scripting.executeScript({ |
| 36 | target, |
| 37 | files, |
| 38 | injectImmediately, |
| 39 | world: chrome.scripting.ExecutionWorld.MAIN, |
| 40 | }); |
| 41 | } |