Skip to content

Development

z0mbi edited this page Oct 10, 2026 · 2 revisions

Development

npm install
node build.js [version] [--no-minify]   # -> cyberspace-atmospheric-modulator.user.js
npm test

The source files in /src are concatenated in order via userscript.config.js into one strict-mode function. The built .user.js is committed so that userscript extensions can do auto updates.

Layout

Path Holds
userscript.config.js The metadata header and the source files, in bundle order
build/ The builder: concatenation, SCSS, exclusions, minification
src/*.js The script's core: config, settings, the feature registry, the user menu, the sidebar button, startup
src/shared/ Code shared between features: storage, dialogs, inputs, theme colors, update check, the settings tab, the Cyberspace API.
src/image-undither/, src/nick-colors/, src/nick-notes/, src/world-clock/ The features
src/exclusions.json Subdomains and paths the script is excluded from running on
docs/themes.txt The site's theme colors, as the site lists them, for keeping THEME_COLORS (src/shared/theme-colors.js) in step. Not part of the build
assets/logo.svg The logo. The README shows it; the build copies its shapes into the sidebar button and the settings tab's heading (textConstants in the config)
overrides.json Site-wide overrides for custom nick colors
CHANGELOG.md What changed in each release. Each version starts with a one-line > summary under its heading, which the update banner shows users of older versions as plain text: at most 160 characters, no ** or links
tests/ Tests, in jsdom

Features

A feature lives in src/<feature>/. Nick colors, nick notes and the world clock each sit in a block of their own (a { scope } group in the config), so their names cannot clash with the rest. A feature joins in through:

  • registerFeature (src/features.js): its switch, boot, storage reload, and its parts of the backup, debug log and issue report,
  • watchUsernames (src/shared/usernames.js): starts the shared username finder, and hears about each name it marks (data-atmo-user),
  • registerUserMenuItem (src/user-menu.js): its user menu items,
  • registerSettingsSection (src/shared/settings-page.js): a section on the settings tab.

Decisions

  • Concatenation, not modules. The script ships as one self-contained file with no runtime dependencies.
  • The settings tab is a hash, not a route. The site has one route per settings tab and no catch-all: /settings/atmomod would match its /:username/:postId page. So the tab is /settings/<current tab>#atmomod.
  • The API through the site's own login. Asking for a password would put it in the userscript so we just borrow the one the site session already holds and never store it.

Clone this wiki locally