D
D
dllweb2016-05-25 17:11:42
JavaScript
dllweb, 2016-05-25 17:11:42

How to send a message from a web page to a chrome extension?

Friends, I still have not figured out the topic, there is really little documentation, are there options for communication between the web page and the chrome extension?
I have such a task that my extension makes some changes on the page, let's say it hides images wider than 200px by default, but in the popup window of the extension there is an interface where, I could choose not 200px, but for example 150 or 100 or 50.
How to access the settings in the popup window of the extension (which, for example, are stored in the localStorage of the background page)
So that in the future my script on the main page of the active tab will be guided by the settings of which images to hide and which not?
I really don’t want to waste time on painful experimental tests, please tell me how to communicate between the main page where the script is being injectedspecified in the manifest

"content_scripts": [
        {
          "matches": [ "*://*/*" ],
          "css": [ "custom.css" ],
          "js": [ "custom.js", "jquery.js" ],
          "run_at": "document_start"
        }

And the extension popup window, thanks for the reply!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2016-05-25
@dllweb

The popup window is almost always closed and cannot respond to messages, so you need to communicate with the background script. Well, how to do it is perfectly described in the documentation .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question