window.navigation.addEventListener("navigate", (event) => { console.log('location changed!'); })window.addEventListener('popstate', function (event) { // The URL changed... }); window.location.href = "www.google.com"; window.addEventListener('hashchange', () => { });var url = window.location.origin + '/foo/foo.php'; history.pushState({}, null, url);history.pushState({}, null, newUrl);var pushState = history.pushState; history.pushState = function () { pushState.apply(history, arguments); fireEvents('pushState', arguments); // Some event-handling function };