Search code examples
google-chromefirefoxidetampermonkeyuserscripts

How to update a userscript's code in Tampermonkey's script storage directly


... 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?


Solution

  • 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)
    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!)


    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