Greasy Fork is available in English.

讨论 » 开发

Tampermonkey's internal editor and @require

PSC
§
发表于:2021-04-11

Hey guys.

I've been writing my own script in Tampermonkey's integrated editor so far, which does a good job of syntax highlighting, but isn't all that great otherwise. So I basically have two questions related to that:

1.) When I use @require to load an external javascript file (library), the tampermonkey editor says it doesn't know the variable I'm using to access those externally loaded methods, but the code works fine. What's the best practice to handle external libraries, to both make the editor believe the variable exists and to make sure the library is available?

2.) What are your suggestions for an external editor/coding environment for userscripts? If you use something like typescript, how do you automatically build the .user.js file?

Thanks for all the help,

PSC

§
发表于:2021-04-11

Built-in Tampermonkey editor is pretty bad, so for anything a little bit serious I just use pic related construction. Access to local files should be enabled for the Tampermonkey, and also all userscript directives still should be changed from Tampermonkey file. You can't declare them from local files

§
发表于:2021-04-11

Empty function at the end is needed because there is some error appears without it.. Don't remember what it is exactly

§
发表于:2021-04-11

how do you automatically build the .user.js file?

I used the Gulp once. Made own configuration that did concatenate files to one

发表回复

登录以发表回复。