开发者

Google Chrome Extension message passing with run_at document_start

开发者 https://www.devze.com 2023-04-13 06:34 出处:网络
I have a question about the executing control between message passing (content_script.js sends request and background.html sends response) andJQuery $(document).ready() function.

I have a question about the executing control between message passing (content_script.js sends request and background.html sends response) and JQuery $(document).ready() function.

I have set "run_at": "document_start" in the manifest file, and according to the doc. the content_script.js will execute after css and before any scripts. In this case, say the content_script.js changes the background color of the html page, the function which can change the page color will be called before any script.

My question is about message passing between content_script.js and background.html.

If I am correct in the following: For example the event

chrome.extension.sendRequest({storage: 'foo'}, function(response) {
      runAfterResponseReceived();});

is defined 开发者_开发问答in the content_script.js, the request will be sent to the background page before any scripts runs. And as soon as this request is sent, other scripts can run, without waiting for the response comes back (unblocking). So when the response is back, content_script.js finds an idle time, and execute function runAfterResponseReceived().

Then, how can I change this to a blocking behavior, so I can have "any scripts" executes after the response is returned.

I hope I have explained my problem. Thanks.


Sorry, not possible. You can star this issue.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号