2

About the popstate, the documentation says this:

Note that just calling history.pushState() or history.replaceState() won't trigger a popstate event. The popstate event is only triggered by doing a browser action such as a click on the back button (or calling history.back() in JavaScript).

So for example, at youtube, if you navigate to another video, the url is changed but how can i detect that change since it wasn't triggered by a browser action?

I would like to do this at the content script, but if impossible, i could do it in the background.

PS:Youtube is just the easiest example of this, so youtube specific solutions, or solutions that depend on youtube maintaining certain id's in the html are not what i'm looking for.

tiagosilva
  • 1,695
  • 17
  • 31
  • Thanks, i appreciate the links, they do give some insights, but i'm looking for a general solution for the issue, and it's not just at youtube, that was just the easier example i could find – tiagosilva Dec 11 '15 at 14:34

1 Answers1

1

You can use webNavigation API and listen for onHistoryStateUpdated event in your background.

e.g:

chrome.webNavigation.onHistoryStateUpdated.addListener(function () {
  // do something here
})
Moin
  • 1,087
  • 1
  • 9
  • 19