When creating a small Chrome extension, I ran into the same problem as the additional problem: sometimes pages change, but not URLs.
For example, just go to the Facebook homepage and click the "Home" button. You reload the page, but the URL does not change (single-page application style).
In 99% of cases, we design websites so that we can receive events from Frameworks such as Angular, React, Vue, etc.
BUT , in my case with the Chrome extension (in Vanilla JS), I had to listen to an event that will fire for each βpage changeβ that can usually be detected when the URL changes, but sometimes itβs not.
My home solution was the following:
listen(window.history.length); var oldLength = -1; function listen(currentLength) { if (currentLength != oldLength) {
Thus, basically the leoneckert solution applied to the window history will change when the page changes in a single-page application.
Not rocket science, but the purest solution I have found, given that we are only checking integer equality here, and not large objects or the entire DOM.
Alburkerk Apr 11 '18 at 10:27 2018-04-11 10:27
source share