Migrating a userscript from Tampermonkey to a JustZix rule
You have a Tampermonkey userscript you want to move to JustZix. Most of the code pastes over unchanged — but a few things work differently. This guide walks you through it step by step.
What pastes over unchanged
Plain JavaScript working on the DOM — querySelector, addEventListener, fetch, MutationObserver — behaves identically. The core of a typical userscript goes into a rule's JavaScript tab and works.
The metadata header — cut it, move it to the UI
The // ==UserScript== block is not code — it is configuration. In JustZix its equivalent is the interface:
| In the userscript | In JustZix |
|---|---|
@match / @include | the rule's URL pattern |
@name | the rule name |
@run-at | rules run after the page loads |
@grant | not needed — see below |
GM_* functions — what is missing and what replaces it
GM_addStyle— not needed: use the rule's CSS tab instead of injecting styles from JS.GM_setValue/GM_getValue— replace with the page'slocalStorageif the data can live with the page.GM_xmlhttpRequest— JustZix has no CORS-bypassing equivalent; a plainfetchworks within the page's CSP.unsafeWindow— not needed: rule code runs in the page context anyway, you have direct access towindow.
What you gain in return
Migration is not just rewriting. In JustZix you get a hierarchy (folder/group/rule), an action bar of on-demand buttons, on-page dev windows and rule sync across devices — things a userscript manager does not have.
Pitfalls
- A userscript loading an external library via
@require— move its code into the rule or load the library in the code itself (within the CSP). - A script relying on a very early start (
@run-at document-start) — JustZix rules start a little later; rarely a problem, but be aware.
See also
- JustZix versus Tampermonkey — comparing the tools' philosophies
- URL patterns — the equivalent of @match
- The folder hierarchy — organization userscripts do not have
Install JustZix — and move your userscripts onto something that grows with you.
Rate this post
No ratings yet — be the first.