The answer from Rob M. does not work for me, because the location of the Tampermonkey script and the destination site where it was entered may differ. For example, in my case, I also have a locally working web server for development in the IDE using Tampermonkey for Firefox without having to access the file system for Tampermonkey from a browser.
This script must be embedded on a third-party site, for example example.com, where it applies modifications. Thus, the browser will block this script, since it is in a different domain than example.com.
During development, I would like my cached script to apply the changes immediately. To work around this, load the contents of the scripts using 'GM.xmlHttpRequest. In addition, the GET parameter with the current timestamp acts as a cache buffer:
let url = 'http://localhost/myscript.js?ts=${(+new Date())}' GM.xmlHttpRequest({ method: "GET", url: url, onload: function(response) { let remoteScript = document.createElement('script') remoteScript.id = 'tm-dev-script' remoteScript.innerHTML = response.responseText document.body.appendChild(remoteScript) } })
Please note that since GM.xmlHttpRequest can bypass the same origin policy, access must be explicitly indicated in the header of your script:
// @grant GM.xmlHttpRequest
source share