0

Is it possible to load a userscript from the local file system, such that updates to the userscript from an external code editor (like VS Code) would automatically reflect in Tampermonkey?

In my case the userscript is part of a cloned git repository, and I find it much easier to make the changes in VS Code, reload the webpage in Chrome to view live results, and commit instantly; than to code in Tampermonkey's JS editor (which is not as good as that of VS Code :(, copy the file to VS Code when I'm done, and then commit it.

I looked around the internet but could not figure out how to do this/if this is possible or not.

I'm using Tampermonkey with Chrome 70, although answers that cover Firefox and others will be appreciated (since I plan to move to other browsers soon)


I looked at the second answer of a similar question. It does not seem to respect @require directives in my userscript. To test this, I quickly added a console.log("test"); to my first @required file and it didn't log. The @requires are critical to my workflow.

Gaurang Tandon
  • 6,504
  • 11
  • 47
  • 84

1 Answers1

2

I found a working solution.

  1. Goto chrome:extensions, search for Tampermonkey, open Details, and check the box for "Allow access to file URLs".
  2. Open the Tampermonkey dashboard.
  3. Drag and drop the script.user.js file into the dashboard.

That's all! :) This method also respects @require directives in your script.user.js file (so if you update one of your @required files, its update is also caught by Tampermonkey).

Gaurang Tandon
  • 6,504
  • 11
  • 47
  • 84
  • I *think* this approach only (re)started working with recent TM changes. Anyway, this answer might best be moved to the duplicate question. – Brock Adams Dec 03 '18 at 18:55