I'm new with chrome extensions (and javascript to be honest) and have managed to create a simple script which copies several DOM elements from the page and kicks up a page containing those elements on page load. It all works fine, however the page where the data is sourced from can change based on user input - ie if they apply some kind of filter.
Rather than running the script when the page loads initially, I would like to be able to hit the extension icon and have this run once. So a user could apply their filter, and run the extension against the page and get the new info in a new popup window.
in manifest file:
"content_scripts": [
{
"matches": ["https://www.oddsmonkey.com/*"],
"js": ["content.js"],
"all_frames": true
}
],
"background": {
"scripts": ["background.js"]
In background.js:
chrome.browserAction.onClicked.addListener(function(tab) {
alert("Hello! I am an alert box!!");
});
Obviously all that happens at button click at the moment is I get an alert box.
I've done a lot of looking around and can't seem to find a way of getting the background.js page (which I understand is required for the button click) to execute content.js. I see the concept of messaging, but I don't need to give anything, or get anything from the content script, I just want it to run!
Hopefully a simple one for someone to answer.
Cheers