How do I get data from a background page to the content script in google chrome extensions

后端 未结 3 1516
清歌不尽
清歌不尽 2020-12-14 20:41

I\'ve been trying to send data from my background page to a content script in my chrome extension. i can\'t seem to get it to work. I\'ve read a few posts online but they\'r

3条回答
  •  庸人自扰
    2020-12-14 21:25

    I thought I'd update this answer for current and future readers.

    According to the Chrome API, chrome.extension.onRequest is "[d]eprecated since Chrome 33. Please use runtime.onMessage."

    See this tutorial from the Chrome API for code examples on the messaging API.

    Also, there are similar (newer) SO posts, such as this one, which are more relevant for the time being.

提交回复
热议问题