Tampermonkey: userscript missing in popup on dynamically loaded pages

Created on 14 Jan 2018  路  4Comments  路  Source: Tampermonkey/tampermonkey

I use @jerone's GitHub JSON dependencies linker userscript intermittently, meaning that I only turn it on when I need it. The problem is that it doesn't show up in the popup when I need to turn it on.

Details:

  • Within the userscript, the @include block has this entry // @include https://github.com/*/package.json to only target specific files on GitHub.
  • To reproduce this issue:

    • Start from any main repo page, e.g. https://github.com/jquery/jquery.

    • Click on the package.json file from that page to navigate to its source page.

    • The userscript does not appear in the popup.

    • Reload the page, and the userscript appears.

Most helpful comment

TM does not detect pushState changes, because it's unclear what to do. Is the script still running or does it need to be injected again? Only the script can make a good choice on how to handle this.

So the solution is to @include all possible source pages and to either use the mentioned PJAX event solution or to overwrite pushState to initiate a normal page load.

Related: #200

All 4 comments

@Mottie Doesn't this have to do with GitHub's PJAX solution... where it doesn't do a full page redirect, but only content update (plus location update). Github JSON Dependencies Linker doesn't include PJAX listeners, like my others scripts do.

No, this is Tampermonkey not showing the userscript in the popup. And I think TM does detect history (URL) changes, so it should work.

If TM indeed detects pushState changes, then yes this script should be in that list on that page.

TM does not detect pushState changes, because it's unclear what to do. Is the script still running or does it need to be injected again? Only the script can make a good choice on how to handle this.

So the solution is to @include all possible source pages and to either use the mentioned PJAX event solution or to overwrite pushState to initiate a normal page load.

Related: #200

Was this page helpful?
0 / 5 - 0 ratings