Adding JavaScript to intercept the window.history.state call from the browser