as official doc says. chrome.scripting.executeScript can wait the promise result. https://developer.chrome.com/docs/extensions/reference/scripting/#promises
but somehow below code can not wait for the result. I'm using manifest_V3
sample = async () => {
let prpmise = new Promise((resolve) => setTimeout(resolve, 1000));
await prpmise;
return "waited";
}
run = async () => {
let tab = await getCurrentTab();
let injectionResults = await chrome.scripting.executeScript({
target: {tabId: tab.id},
func: sample,
args: []
});
console.log(injectionResults);
console.log(injectionResults[0].result);
}
I can see console log output as empty object. when I use other function using synchronous return, it returns value, and it works as I expexted.