I'm trying to build a Chrome Extension that needs to send a POST request to a server when the user is on a certain url/path.
I have that part working, except the code I have right now only runs when I click on the icon of my Chrome Extension, how would I make the code run every time I'm on a certain url?
I also need data stored in chrome.storage to be accessible in the code that runs every time aswell
Open the Extensions by clicking the puzzle icon next to your profile avatar. A dropdown menu will appear, showing you all of your enabled extensions. Each extension will have a pushpin icon to the right of it. To pin an extension to Chrome, click the pushpin icon so that the icon turns blue.
Go to chrome://extensions in your Google Chrome browser. Check the Developer mode checkbox in the top right-hand corner. Click “Load Unpacked” to see a file-selection dialog. Select your extension directory.
The answer is to use a content script
Specify the matching url in your manifest.
A background page is always running, but the content script is only injected on specific pages (you can specify before/after load end)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With