1

I'm writing a userscript for a GWT-based site.

My script uses URL of the page as input. It should be update each page of the site with additional information.

Unfortunately, as view changes in GWT are implemented via rerendering (only location anchor in browser address-bar is being changed), clicks on internal links are not recognized as page loads and Greasemonkey does not invoke my script, leaving new views unmodified.

Is there a way to hook in GWT-based navigation from an userscript? I need a way to modify each "change" Gerrit navigates to.

Complete workflow should look like:

  • User scans through the list of issues
  • User clicks on a link a link in Gerrit search results. (Address bar will assume a location of a change being clicked, for example https://git.eclipse.org/r/#/c/38781/)
  • Page is modified by userscript to contain information about new view (in our case /c/38781/)

Greasemonkey is only invoked at the first step of this workflow, and I don't know ho to detect second one to be able to trigger the third.

I've tried to observe DOM changes on the page, but my listeners are never called probably due to the fact GWT renders some parts via innerHTML property, without explicit child manipulation.

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
Basilevs
  • 22,440
  • 15
  • 57
  • 102
  • possible duplicate of [How do I reload a Greasemonkey script when AJAX changes the URL without reloading the page?](http://stackoverflow.com/questions/18989345/how-do-i-reload-a-greasemonkey-script-when-ajax-changes-the-url-without-reloadin) – Brock Adams Dec 28 '14 at 09:06
  • `hashchange` probably fires and Mutation Observers *will* work if you set them up properly, but just use polling if `hashchange` isn't enough. Polling is simple, easy, and works every time (as long as it's not abused). – Brock Adams Dec 28 '14 at 09:09
  • 1
    @BrockAdams thank you, "hashchange" works. – Basilevs Dec 28 '14 at 17:07

0 Answers0