Eugene Bos
unread,Dec 18, 2023, 1:31:09 PM12/18/23Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Chromium Extensions
I'm using a content script that receives data from `chrome.storage.local.get` and then executes.
I want it to complete all execution before the website's scripts start executing.
The problem is: that getting data from `chrome.storage.local.get` takes time and is asynchronous, so it starts to execute before the website's scripts but finishes after.
Is there a way to fix it? Like, block the main thread before it finishes or something? Or pass information to it without using `chrome.storage.local.get`? Or should I delay all requests of the page with `chrome.webRequest`?
"content_scripts": [
{
"run_at": "document_start",
"matches": ["<all_urls>"],
"js": ["content.js"],
"match_about_blank" : true
}
],
content.js:
(async () => {
// website's scripts are not yet executed
let data = await chrome.storage.local.get("data");
// website's scripts are already executed
})();