You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/posts/how-to-edit-scripts-with-your-favorite-editor/index.md
+11-28Lines changed: 11 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,43 +5,26 @@ tags:
5
5
- editor
6
6
---
7
7
8
-
Since Violentmonkey is a lightweight script manager by design, its editor is simple and offers just a few options. It doesn't try to replicate a full-featured editor or IDE, which is problematic anyway due to browser's hardcoded hotkeys and other restrictions.
8
+
Since Violentmonkey is lightweight by design with a simple built-in editor featuring just a few customizations in the extension's options, we encourage you to use an external editor or IDE that's not restricted by browser quirks like the hardcoded hotkeys or performance limitations.
9
9
10
-
<details>
11
-
<summary>Screenshot of the built-in editor and its options</summary>
10
+
⚡ Simply open the local `.user.js` file in Violentmonkey and enable tracking, so each time you save the file in your external editor the changes are automatically incorporated.
12
11
13
-

14
-
15
-
Customization in the extension's settings:
16
-
17
-

18
-
19
-
</details>
20
-
21
-
<br/>
22
-
23
-
Excellent external editors exist and using one to edit scripts in Violentmonkey is relatively simple, no need to reinvent the wheel.
12
+
Now let's dive into the details.
24
13
25
14
## 1. One-time preparation
26
15
27
16
1. Copy the code of the script from Violentmonkey into your editor.
28
17
2. Save it to a file and give it a name ending with `.user.js`
29
18
30
-
## 2. Open this file in Violentmonkey installer
31
-
32
-
⚠ The local file's name must end with `.user.js`, otherwise it won't be recognized by Violentmonkey. The only exception is method 2.1, which recognizes any `.js` file because you explicitly drag it into the extension.
33
-
34
-
You can use any of these methods listed in the order of increasing complexity:
35
-
36
-
#### 2.1. Drag the file into any Violentmonkey tab or popup
19
+
## 2. Open `.user.js` file in Violentmonkey installer
37
20
38
-
⚠ Only implemented in Chrome/Chromium 86 or newer and Violentmonkey 2.16 or newer.
21
+
#### 2.1. Drag `.user.js` file into any Violentmonkey UI page [Chrome only]
39
22
40
-
⚡ Chromium 133 and newer improves performance of detection via `FileSystemObserver` API. Chromium 129-132 can use it too if you go to `chrome://flags/#enable-experimental-web-platform-features` and enable this flag, then restart the browser.
23
+
* Chrome [86 or newer](https://caniuse.com/mdn-api_datatransferitem_getasfilesystemhandle), Violentmonkey 2.16 or newer. This is the most performant method since Chrome 133 that implemented `FileSystemObserver` API to notify of file changes.
41
24
42
-
⚡ If you assigned a hotkey to activate Violentmonkey in the browser's options for extensions, you can press it while dragging the file, which opens the extension's popup into which you can drop the dragged file.
25
+
* If you assign a hotkey to activate Violentmonkey in the browser's options for extensions, you can press it *while dragging the file*.
43
26
44
-
#### 2.2. Drag the file into the browser toolbar or tab label area
27
+
#### 2.2. Drag `.user.js` file into the browser toolbar or tab label area
45
28
46
29
* 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.
47
30
@@ -59,7 +42,7 @@ You can use any of these methods listed in the order of increasing complexity:
59
42
60
43
## 3. Enable tracking
61
44
62
-

45
+

63
46
64
47
Click `Track external edits` button to confirm installation and start tracking.
65
48
@@ -71,9 +54,9 @@ As long as the installer tab is open it will track your local file and install t
71
54
72
55
* The `Stop tracking` button may be useful for example when temporarily switching branches in your git repo. When finished, you can click `Track external edits` again.
73
56
74
-
* The `Reload tab` option allows you to switch to another tab with a website [matched](/api/matching/) by this script, so that this tab will be reloaded automatically when changes are detected and this script still matches the tab's URL.
57
+
* The `Reload tab` option will automatically reload the active tab if it contains a website [matched](/api/matching/) by this scriptwhen changes are detected.
0 commit comments