2

I am working with a Chrome extension intended to improve the behaviour of the Inspera digital exam platform (the server side of which I cannot influence in any way). One annoying property of this platform is that all pages within its website, without exception, have the same <title> value, "Inspera Assessment". Therefore, the browser's "Back" button menu becomes utterly uninformative, see image 1.

back button menu without extension

In order to improve this situation, I included changes to the page titles in my extension's code, $("title").text([my new title text]); . While that made the page titles much more informative, it also revealed that the "Back" button history menu had two or three consecutively repeated items for each page at the site that had been visited (once each, see Image 2).

back button menu with extension

I think I have established that this behaviour is not caused by my extension (rather, one could suspect that that the company's choice of uniform page title might have been intended to conceal this). My questions are:

  1. Is there a good guess for what might have caused the duplication of items in the back button menu? and could one hope to remedy that within the scope of an extension?
  2. assuming there isn't, is there any way to programatically weed out the duplicate items from the client's browser?
danbae
  • 563
  • 2
  • 8
  • 22
  • 1) set a breakpoint in the page code that calls history.pushState and investigate - it may be a bug in the site, 2) you can override history.pushState in [page context](/a/9517879) so your hook will analyze the parameters and skip invocation (or call history.replaceState) if they're identical to the previous ones stored in some variables in your code. – wOxxOm Jun 26 '20 at 02:55
  • @wOxxOm: Your advice has always been excellent, and I'm sure that's the case now as well. However, I don't think I'm knowledgeable enough to make use of it this time. Reading through the [History API documentation](https://developer.mozilla.org/en-US/docs/Web/API/History), I cannot find out whether or how I could access a list of the client's browsing history or remove items from it. It seems `pushState()` adds states to the history, which is not really what I'm after. I managed to listen to `popstate` events, but these only seem to fire once per page visit. – danbae Jun 26 '20 at 11:07
  • What you observe is caused by the use of history.pushState. This is how it works. You can find examples of spoofing/hooking/intercepting for pushState (or any other standard method). Your hook will store the previous URL and optionally the state object in a variable and compare that to the current parameters. – wOxxOm Jun 26 '20 at 11:43
  • @wOxxOm 2 questions: 1) am I right in understanding that the `state` object only gets its content from intervention with `pushState()` and does not provide any information from the browser – the name "state" somewhat misled me (I would have preferred "label" or "info")? 2) your description of how to intervene in the page code with breakpoints and the like seems to assume that the code running the page is present on the page. Not so – almost all the js is remote, very long, and minified. So I guess it's kind of hard to work with that? – danbae Jul 02 '20 at 11:27
  • 1) yes, 2) the origin of the code doesn't matter. – wOxxOm Jul 02 '20 at 11:49
  • So if I understand this right: if there is a script added as a ` – danbae Jul 03 '20 at 09:34
  • No, you don't need the originals at all. Simply add a new script element with the hook/intercept code for `history.pushState`, see the link in my first comment. – wOxxOm Jul 03 '20 at 09:37

0 Answers0