Well, I want to know if its possible to recall a Tampermonkey script when a user changes his location (but the match is still active). For example, my scripts hooks youtube website.
I need to make that the script recalls itself when I change the video, my actual script is:
// ==UserScript==
// @name xxx
// @namespace xxx
// @version 1.0
// @description xxx
// @author Ikillnukes
// @match https://www.youtube.com/*
// @match https://youtu.be/*
// @grant none
// ==/UserScript==
console.log("Tampermonkey hook!");
var script = document.createElement('script');
script.src = document.location.protocol+"//xxx";
(document.body || document.head || document.documentElement).appendChild(script);
As you can see I call console.log for debug it, and it gets called when I refresh or I load the webpage for the first time. But one time I change the video it doesn't get called anymore, and that is what I want to avoid.
I also reviewed this: http://tampermonkey.net/documentation.php and I didn't find anything, maybe I reviewed it too quickly?
So, any suggestions there?
Listen to the custom events used by the youtube script:
window.addEventListener("yt-navigate-start", e => { console.log(e.type); });
window.addEventListener("yt-navigate-finish", e => { console.log(e.type); });
To see all these events in Chrome:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With