Manifesto:
{ "manifest_version": 2, "name": "Test", "description": "Тест расширения", "version": "1.1", "icons": { "128": "128.png" }, "browser_action": { "default_popup": "index.html" }, "permissions": [ "activeTab" ], "background": { "scripts": [ "jquery.js", "background.js" ] }, "content_scripts": [ { "matches": ["http://*/*"], "css": ["style.css"], "js": ["jquery.js","popup.js"] } ] } Background.js
chrome.runtime.onMessage.addListener( function(request, sender, sendResponse) { console.log(sender.tab ? "from a content script:" + sender.tab.url : "from the extension"); if (request.greeting == "hello") sendResponse({farewell: "goodbye"}); }); Popup.js
chrome.runtime.sendMessage({greeting: "hello"}, function(response) { console.log(response.farewell); }); If you go to some site with http: // then there will be goodbye in the console, if I understood correctly, then we roughly send the hello message to the extension, there is a check and the answer is sent, "goodbye"
How to get data from the page to the extension?
Example: take some block from Yandex with id="data" (for example), get the contents var b = $('#data').text(); and pass to your extension and, for example, insert into your markup, approximately into a block with id="test" .... $('#test').text(b);
Can you voluntarily direct you to the right path? To give a small example in general would be a miracle =) Thank you.