(config = {})
| 384 | }; |
| 385 | |
| 386 | export const runScriptInTab = async (config = {}) => { |
| 387 | return new Promise((resolve, reject) => { |
| 388 | chrome.scripting.executeScript( |
| 389 | mergeObject( |
| 390 | { |
| 391 | world: "MAIN", |
| 392 | injectImmediately: true, |
| 393 | }, |
| 394 | config |
| 395 | ), |
| 396 | (injectionResults) => { |
| 397 | if (chrome.runtime.lastError) { |
| 398 | console.error(chrome.runtime.lastError); |
| 399 | reject(chrome.runtime.lastError); |
| 400 | } |
| 401 | // https://developer.chrome.com/docs/extensions/reference/scripting/#handling-results |
| 402 | else resolve(injectionResults?.find?.((_) => _.result)?.result); |
| 403 | } |
| 404 | ); |
| 405 | }); |
| 406 | }; |
| 407 | |
| 408 | export const runScriptFile = (config = {}) => { |
| 409 | return new Promise((resolve, reject) => { |
no test coverage detected