Discussions » Development

Problem with scipt not loading

§
Posted: 2019-12-21
Edited: 2019-12-21

Problem with scipt not loading

Hi, I have written a small script that should run at document-idle and execute certain actions. The problem however which I have with it is that it's not launched when I visit the concerned page using hyperlink from another page on the same site. The script only launches when I'm on the page and force manual reload. When I check Tampermonkey menu after first load, the script is not even listed among active scripts, though the @match clause is absolutely right. Apparently the web uses certain nonstandard pages loading which prevents Tampermonkey to detect the page address and load the respective script.

§
Posted: 2019-12-22

The problem is what site are your script run in, some modern design website do not use the common method to open the a link in same site, they use history.pushState or history.replaceState to modify the location diretly so most resources have not to be reload, that can save time spend on loading resources. Addition some site also modify history.pushState and history.replaceState to make extra funtion. In order to run script on these sites, you have to @match whole domain and hack history.pushState and history.replaceState to observe the location change, or maybe there are some event trigger when the page change on special website, find and observe them and pick the time to run your script

wOxxOmMod
§
Posted: 2019-12-22

An example of event-based solution mentioned by indefined: https://stackoverflow.com/a/34100952

Post reply

Sign in to post a reply.