Skip to content

Commit 75a08b2

Browse files
committed
doc: update fav editor article
1 parent 2b3ef7b commit 75a08b2

File tree

5 files changed

+12
-15
lines changed

5 files changed

+12
-15
lines changed
-17.2 KB
Loading
-39.2 KB
Loading
Binary file not shown.
Binary file not shown.

content/posts/how-to-edit-scripts-with-your-favorite-editor/index.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,40 +36,37 @@ Install a local script
3636

3737
First make sure the local script is named with a suffix of `.user.js`.
3838

39-
There are two ways to install a local script:
39+
Then use one of these methods:
4040

41-
- *Easy way:* drag the file into the browser.
41+
- Drag the file into any Violentmonkey tab or popup.
4242

43-
It will be recognized by Violentmonkey and loaded in the confirmation page.
43+
Requires Chrome/Chromium 86+ and Violentmonkey 2.16+.
4444

45-
Make sure *"Allow access to file URLs"* is checked in your *Chrome extension settings* (`chrome://extensions`).
45+
- Drag the file into the browser toolbar or tab label area.
4646

47-
![](editor-6.png)
47+
* In Chrome-like browsers you must enable *"Allow access to file URLs"* in Violentmonkey's details in `chrome://extensions` page first. Since this is dangerous (any userscript will be able to read any local file via GM_xmlhttpRequest), you may want to use the other methods instead.
4848

49-
**Note** that due to a [known issue](#known-issues), the *easy way* **won't work for Firefox users**.
49+
* In modern Firefox-like browsers don't close the file tab while tracking as it's used to read the contents of the file.
5050

51-
- *Hard way:* start a local HTTP server, then open the local script with a URL like `http://localhost:8080/my-script.user.js`.
51+
- Set up a server and navigate to `http://localhost:8080/my-script.user.js`.
5252

53-
One of the best way is to use node/npm's [indexzero/http-server](https://github.com/indexzero/http-server#readme). If you have it installed, just type `http-server -c5` at the directory of your script to start a server.
53+
The port number `:8080` may be different or even omitted depending on the server you installed.
5454

55-
Make sure the hostname is `localhost` and the script name ends with `.user.js`.
55+
We recommend [indexzero/http-server](https://github.com/indexzero/http-server#readme). Once you install it, just type `http-server -c5` at the directory of your script to start a server. The `-c5` option sets cache time for max-age header to 5 seconds ([more info](https://github.com/violentmonkey/violentmonkey/issues/460#issuecomment-434335758)), thus forcing a browser to query the server URL every 5 seconds. The caching can be disabled with `-c-1` option.
5656

57-
**Note** that due to a [known issue](https://github.com/violentmonkey/violentmonkey/issues/460#issuecomment-434335758), the *hard way* needs to handle caching. In `http-server -c5` option `-c5` sets cache time for max-age header to 5 seconds, thus forcing a browser to query the server URL every 5 seconds. The caching can be disabled with `-c-1` option.
57+
Make sure the hostname is `localhost` and the script name ends with `.user.js`.
5858

5959
![](editor-3.png)
6060

61-
Make sure the `track local file` option is checked and then confirm installation.
62-
63-
![](editor-4.png)
61+
Click `Track external edits` button to confirm installation. You can also make it the default button for local files by ticking the checkbox on the right.
6462

6563
Edit and sync
6664
---
6765

6866
After installation, the confirmation page will keep watching the file before the page is closed. Once the file is changed, the new version will be installed automatically. As a result, you edit the script in your favorite editor, and the changes are synced to Violentmonkey immediately.
6967

70-
![](editor-5.png)
68+
![](editor-4.png)
7169

7270
Known issues
7371
---
74-
- In Firefox Violentmonkey is not allowed to access local files, so we have to start a local HTTP server for tracking. See [this on bugzilla](https://bugzilla.mozilla.org/show_bug.cgi?id=1266960).
7572
- The older the file is, the more seldom a browser will query it. See [this Violentmonkey's issue](https://github.com/violentmonkey/violentmonkey/issues/460#issuecomment-434335758).

0 commit comments

Comments
 (0)