Answer the question
In order to leave comments, you need to log in
How to get background response before page load?
manifest
/**/
"run_at": "document_start"
/**/
console.log('Extension Init');
chrome.extension.sendMessage('init', function(back)
{ console.log('sendMessage request');
console.log(back)
});
chrome.extension.onMessage.addListener(function(request, sender, f_callback)
{
f_callback('back message');
});
<html>
<head>
</head>
<body>
<script>
window.onload = function(){console.log('ONLOAD');};
</script>
</body>
</html>
Extension Init
ONLOAD
sendMessage request
back message
Answer the question
In order to leave comments, you need to log in
I don’t know if it’s possible to redefine the order of calling scripts, but when I myself wrote an extension for chrome using localstorage, I did something like this:
background.js:
function run(){
chrome.storage.local.get('param', function(data){
startApp(data);
}
}
function startApp(){//....}
run();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question