I am trying to use chrome.windows.onCreated
but I got Uncaught TypeError: Cannot read property \'onCreated\' of undefined
. I noticed in the samples
From the documentation for Content scripts:
However, content scripts have some limitations. They cannot:
- Use
chrome.*
APIs (except for parts of chrome.extension)- Use variables or functions defined by their extension's pages
- Use variables or functions defined by web pages or by other content scripts
These limitations can indirectly be avoided, mainly by sending messages within the extension. The documentation offers several examples which involves message passing. Prior Chrome 20, the message API methods was called onRequest
and sendRequest
. Since version 20, they're called onMessage
and sendMessage
.
Here's an answer which mentions the steps how to pass a message from a content script to a popup: https://stackoverflow.com/a/11617742