Skip to content

Commit bcd5f30

Browse files
committed
Resolve toTab() promise when all scripts have been injected
1 parent c631ad7 commit bcd5f30

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,18 @@ export async function addToTab(tab = false) {
1818
try {
1919
const tabId = tab.id || tab;
2020
if (!await pingContentScript(tabId)) {
21+
const injections = [];
2122
for (const group of chrome.runtime.getManifest().content_scripts) {
2223
const allFrames = group.all_frames;
2324
const runAt = group.run_at;
2425
for (const file of group.css) {
25-
p(chrome.tabs.insertCSS, tabId, {file, allFrames, runAt});
26+
injections.push(p(chrome.tabs.insertCSS, tabId, {file, allFrames, runAt}));
2627
}
2728
for (const file of group.js) {
28-
p(chrome.tabs.executeScript, tabId, {file, allFrames, runAt});
29+
injections.push(p(chrome.tabs.executeScript, tabId, {file, allFrames, runAt}));
2930
}
3031
}
32+
return Promise.all(injections);
3133
}
3234
} catch (err) {
3335
// Probably the domain isn't permitted.

0 commit comments

Comments
 (0)