如何直接在Tampermonkey的脚本存储中更新用户脚本的代码

huangapple go评论69阅读模式
英文:

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/&lt;user&gt;/.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脚本。以下是操作步骤:

  1. 安装Tampermonkey Editors扩展程序
  2. 完成。

安装后,当您单击“Tampermonkey Editors”图标时,它将带您进入vscode.dev,并自动打开包含所有已安装Tampermonkey脚本的“文件夹”。

一些注意事项:

a. 您的脚本按照命名空间(// @namespace行)分组。
b. 来自VS Code桌面应用程序的一些重要扩展不起作用(例如,Allessandro Fragnani的必备“Numbered Bookmarks”扩展目前不可用 - 事实上,截至撰写本文时,没有可用的书签扩展程序。没有书签。啊呜!)


第二选项(本地)

您还可以使用本地安装的VSCode实例来编辑您的脚本,使用这种(较旧的)方法 - 但是,由于第一步,这可能只适用于Chromium浏览器:

  1. 转到您的Chrome扩展程序设置,并启用“允许访问文件URL”。
  2. 在Tampermonkey编辑器中,您只需要一个空白脚本,//requires包含您实际代码的js文件。
  3. 您可以使用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:

  1. Install the Tampermonkey Editors extension
  2. 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:

  1. Go to your Chrome extension settings and turn on "Allow access to file URLs".
  2. In the Tampermonkey editor, all you need is a blank script that //requires the js file that contains your actual code.
  3. 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:

https://github.com/Tampermonkey/tampermonkey/issues/1654

https://www.tampermonkey.net/changelog.php#v4.19.0

huangapple
  • 本文由 发表于 2023年6月12日 01:11:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/76451614.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定