Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid caching required scripts #723

Open
matt-tingen opened this issue Jun 10, 2019 · 12 comments
Open

Avoid caching required scripts #723

matt-tingen opened this issue Jun 10, 2019 · 12 comments

Comments

@matt-tingen
Copy link

matt-tingen commented Jun 10, 2019

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
Copy link
Author

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

@derjanb
Copy link
Member

derjanb commented Jul 26, 2019

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

@0xCA
Copy link

0xCA commented Oct 14, 2019

@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
Copy link

mnn commented Jul 27, 2020

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
Copy link

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
Copy link

xdhmoore commented Feb 8, 2022

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
Copy link

Shi-553 commented Nov 13, 2022

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
Copy link

Hi Team,

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

@rRobis
Copy link

rRobis commented Mar 26, 2023

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
Copy link

rRobis commented May 24, 2023

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
Copy link

Mrgaton commented Apr 24, 2024

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

@Mrgaton
Copy link

Mrgaton commented Apr 24, 2024

// @grant        GM.xmlHttpRequest
// @grant        GM.getValue
// @grant        GM.setValue

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants