sendMessage from extension background or popup to content script doesn't work

后端 未结 4 953
孤街浪徒
孤街浪徒 2020-12-02 05:38

I know that question has been repeatedly asked in different ways, but I tried to go through all the answers (hopefully I didn\'t miss anyone) and none of them worked for me.

4条回答
  •  甜味超标
    2020-12-02 06:14

    @apsillers is correct. Also don't forget to return true in your content-script listener or it might close too early.

    chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
        console.log(message)
        return true
    });
    

提交回复
热议问题