Tyler Chong
Tyler Chong

Reputation: 710

How to make a Chrome Extension run code when on a certain url

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

Upvotes: 9

Views: 9615

Answers (1)

neaumusic
neaumusic

Reputation: 10454

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)

Upvotes: 7

Related Questions