英文:
How to update a userscript's code in Tampermonkey's script storage directly
问题
...这使得我能够使用我喜欢的集成开发环境进行开发,而不必反复将代码复制粘贴到TM的“编辑”窗口中吗?
我找到了/home/<user>/.mozilla/firefox/t1b9jtvd.default-release/storage/default/https+++www.tampermonkey.net/ls/data.sqlite
,并使用FF的SQLite Manager打开它,但在那里没有找到脚本的表格。
根据一个回答 Chrome/Tampermonkey用户脚本在文件系统中存储在哪里?:
> 更新: 从 版本3.5.3630 开始,Tampermonkey脚本现在使用Chrome的扩展存储进行存储。
但它们在FF中存储在哪里,如何从外部访问它们呢?还有,如何从外部访问Chrome的扩展存储?
英文:
... such being able to use my preferred IDE for developing and avoiding C&Ping the code into TM's Edit window very, very often repeatedly?
I found /home/<user>/.mozilla/firefox/t1b9jtvd.default-release/storage/default/https+++www.tampermonkey.net/ls/data.sqlite
and opened it with FF's SQLite Manager but didn't find a table for scripts there.
According to an answer to Where are Chrome/Tampermonkey userscripts stored on the filesystem?:
> Update: As of version 3.5.3630, Tampermonkey scripts are now stored using Chrome's extension storage.
But where are they stored in FF and how to access them from the outside world there? And, how to access Chrome's extension storage from the outside world?
答案1
得分: 2
第一选项(在线)
使用新的Tampermonkey Editors扩展程序。
从版本4.19.0开始,Tampermonkey现在允许您使用VS Code Online编辑您的Tampermonkey脚本。以下是操作步骤:
- 安装Tampermonkey Editors扩展程序。
- 完成。
安装后,当您单击“Tampermonkey Editors”图标时,它将带您进入vscode.dev,并自动打开包含所有已安装Tampermonkey脚本的“文件夹”。
一些注意事项:
a. 您的脚本按照命名空间(// @namespace
行)分组。
b. 来自VS Code桌面应用程序的一些重要扩展不起作用(例如,Allessandro Fragnani的必备“Numbered Bookmarks”扩展目前不可用 - 事实上,截至撰写本文时,没有可用的书签扩展程序。没有书签。啊呜!)
第二选项(本地)
您还可以使用本地安装的VSCode实例来编辑您的脚本,使用这种(较旧的)方法 - 但是,由于第一步,这可能只适用于Chromium浏览器:
- 转到您的Chrome扩展程序设置,并启用“允许访问文件URL”。
- 在Tampermonkey编辑器中,您只需要一个空白脚本,//requires包含您实际代码的js文件。
- 您可以使用VScode编辑该js文件。
额外提示:一旦您可以编辑本地文件,这也打开了使用构建系统(如webpack或其他您喜欢的工具)的能力。压缩您的脚本。将其拆分为不同的文件。从typescript转译。尽情发挥吧。
参考链接:
https://github.com/Tampermonkey/tampermonkey/issues/1654
https://www.tampermonkey.net/changelog.php#v4.19.0
英文:
Option The Firste (online)
Use the new Tampermonkey Editors extension.
As of version 4.19.0, Tampermonkey now allows you to edit your Tampermonkey scripts using VS Code Online. Here's how:
- Install the Tampermonkey Editors extension
- That's it.
After installation, when you click the "Tampermonkey Editors"' icon it will take you to vscode.dev and a "folder" with all installed Tampermonkey scripts should be automatically opened.
A few notes:
a. Your scripts are grouped by Namespace (the // @namespace
line)<br>
b. Some essential extensions from the VS Code desktop app do not work (for e.g., Allessandro Fragnani's essential "Numbered Bookmarks" extension is not available - in fact, no bookmark extension is available as of this writing. No bookmarks. Auuugh!)
<hr>
Option The Seconde (local)
You can also use your locally-installed VSCode instance to edit your scripts, using this (older) method - however, this might only work on Chromium browsers because of step-the-first:
- Go to your Chrome extension settings and turn on "Allow access to file URLs".
- In the Tampermonkey editor, all you need is a blank script that //requires the js file that contains your actual code.
- You can use VScode to edit that js file.
Extra note: Once you can edit local files, this also opens up the ability to use build systems like webpack or whatever else you fancy. Minify your script. Split it into different files. Transpile from typescript. Go wild.
References:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论