Tampermonkey: In special situation, Tampermonkey is not starting scripts even though it is on the right url.

Created on 7 Aug 2019  路  2Comments  路  Source: Tampermonkey/tampermonkey

Some background:

I am using a system with the following specifications:

  • Chrome: 75.0.3770.142
  • TM: 4.8.41
  • OS: Windows 10 OS Version 1803 (Build 17134.885)

This issue appears for me on flickr.com.

  1. Start by installing the following script
    js // ==UserScript== // @name A Flickr script // @Version 1.0 // @description try to take over the world! // @match https://www.flickr.com/photos/* // @match https://www.flickr.com/photos/*/* // @grant none // ==/UserScript==
  2. Then go to this(https://www.flickr.com/people/usnavy/) page.
  3. On that page click on the Photostream link. (This should take you to https://www.flickr.com/photos/usnavy/ but you need to do it on the website to see the effect)

Expected Behavior

  1. The browser should change to the url https://www.flickr.com/photos/usnavy/.
  2. The script above should be activated on that page.

Actual Behavior

  1. The browser changes to the url https://www.flickr.com/photos/usnavy/.
  2. The script above is _not_ activated on that page.

Most helpful comment

It is because flickr use "history api" and ajax to fetch the new page, and this didn't trigger page reload so Tampermonkey won't load.
You can verify that by using this script:

// ==UserScript==
// @name A Flickr script
// @Version 1.0
// @description try to take over the world!
// @match https://www.flickr.com/*
// @grant none
// ==/UserScript==

const fn=history.pushState.bind(history)
history.pushState=(...args)=>{
    console.log(args)
    fn(...args)
}

All 2 comments

It is because flickr use "history api" and ajax to fetch the new page, and this didn't trigger page reload so Tampermonkey won't load.
You can verify that by using this script:

// ==UserScript==
// @name A Flickr script
// @Version 1.0
// @description try to take over the world!
// @match https://www.flickr.com/*
// @grant none
// ==/UserScript==

const fn=history.pushState.bind(history)
history.pushState=(...args)=>{
    console.log(args)
    fn(...args)
}
Was this page helpful?
0 / 5 - 0 ratings