Tampermonkey / tampermonkey

Tampermonkey is the most popular userscript manager, with over 10 million users. It's available for Chrome, Microsoft Edge, Safari, Opera Next, and Firefox.
GNU General Public License v3.0
4.28k stars 423 forks source link

Avoid caching required scripts #723

Open matt-tingen opened 5 years ago

matt-tingen commented 5 years ago

Any chance the suggestion in #475 (@-directive to avoid caching externals) could be reconsidered given #347? Without file:// access in Firefox, there's not a great way to develop scripts.

My method of dev in Chrome was to generate the header once with file:// URLs and edit the required scripts in my own editor. This was great because I can just make changes, switch to the browser, and reload. With Firefox I can use a local server to work around the file:// limitation, but I would have to also increment the version within Tampermonkey as part of the dev cycle.

Alternatively to an @-directive, perhaps an option to set e.g. a domain blacklist for which resource won't be cached. Then I could add e.g. localhost:8080 to the list and it would function like file:// URLs.

matt-tingen commented 5 years ago

I gave tamperdav a try, but it being mutually exclusive with browser sync makes it a hard sell.

derjanb commented 5 years ago

@matt-tingen Have you seen this https://github.com/Tampermonkey/tampermonkey/issues/475#issuecomment-348594785 especially point 2?

0xCA commented 5 years ago

@matt-tingen Have you seen this #475 (comment) especially point 2?

So you might need to execute/load the page twice.

That is exactly what we would like to avoid. Need a way to have just one page reload as with file require.

mnn commented 4 years ago

Would love to see this implemented (preferably as a whitelist to not wait every time for download of 3rd party libraries). I am using webpack-userscript and it works well, but the need to always refresh three times before Tampermonkey picks up changes is annoying.

wisedevman commented 3 years ago

It would be very useful. On firefox, the only way I found to get the required script updated in one time is to add a ?whatever after the address of script and change the part after the ? before saving the script. TM see it as a new script and download it everytime.

xdhmoore commented 2 years ago

I would also love to see this. My current dev setup is to use a local server and just include the userscript headers in TM. The biggest pain point is having to manually open up the dashboard and increment my script version for every change I build/deploy. The option to turn off caching would be awesome.

Shi-553 commented 1 year ago

Reloading is tedious, so I created a simple script that retrieves the file with GM.xmlHttpRequest and reloads it if it has changed.

// ==UserScript==
// @name         name
// @version      0.1
// @match        https://
// @grant        GM.xmlHttpRequest
// @grant        GM.getValue
// @grant        GM.setValue
// @require      LOCALHOST_URL
// ==/UserScript==

(async function() {
    GM.xmlHttpRequest({
        url: LOCALHOST_URL,
        onload:  async(response) => {
            const text=response.responseText;
            const storageData = await GM.getValue("CachedScriptKey");

            if(text!=storageData){
                console.log("reload!");

                await GM.setValue("CachedScriptKey",text);
                location.reload();
            }else{
                console.log("NO reload!");
            }
        }
    });
})();
guanlinz commented 1 year ago

Hi Team,

Any updates on this? my team is facing the same issue

rRobis commented 1 year ago

Currently, I use local http server, and load JS files from it with @require.

But I have to do 1 force cache reload and 2 reloads in my firefox browser (even though in the externals it seems that it updates even before that).

Please, find a solution, I develop userscripts on daily basis, and this is such a pain to reload 3 times😄

rRobis commented 1 year ago

If anyone needs, look at this solution, that i'm experimenting with. It seems that it's working even on firefox.

347 My last comment

Mrgaton commented 6 months ago

it would be great to be able to use like variables on the // @require like %random% and put it on the query

Mrgaton commented 6 months ago
// @grant        GM.xmlHttpRequest
// @grant        GM.getValue
// @grant        GM.setValue

the only problem is that tampermonkey is asking me special permisions for the xmlHttpRequest