RoyalRefresh
A web extension for royalroad.com.
For people who juggle multiple stories.
Install
Why?
I’ve been an avid reader on royalroad.com since 2019 and like many others, I juggle
multiple stories at the same time. At some point this got somewhat unmanageable and often I drew a blank when thinking
about what happened in the last chapter of the story I just opened. More and more I found myself having to go back one
chapter and scroll all the way down just to re-read the last few paragraphs as a refresher. This is especially annoying
while on mobile, where I often read while on the train.
That’s when I decided on trying to implement this little idea — a refresh of what happened in the last chapter.
What is it?
RoyalRefresh is a browser extension for royalroad.com that inserts a button next to RoyalRoad’s
“Reader Preferences” button on chapter URLs. When clicked, the last few paragraphs of the previous chapter get fetched
and displayed at the top of the chapter, which you can toggle on and off using the button. The extension defaults to
showing you the last 250 words of the previous chapter (adjustable in extension settings, see Settings).
Here’s an example of what it looks like:

Settings
The extension comes with a settings page where you can adjust the refresh length and other settings.
There are a few ways to access the settings page:
- Click the extension icon in the browser toolbar to open the popup (Recommended)
- Open RoyalRoad’s “Reader Preferences” menu and click “Open RoyalRefresh settings”
- Depending on your browser, there may be alternative methods to access the extension settings,
(such as using
about:addons in Firefox)
Basic Settings popup

Advanced users can change CSS selectors in the settings if the site design changes, until a new extension update is pushed.
[!NOTE]
Advanced settings for CSS selectors are only available in the full extension settings page, not in the popup. Use the
popup to quickly access basic settings, but open the full settings page for advanced configuration.
Advanced settings

Tech Stack
This extension is built using:
- WXT: A framework for building web extensions with a modern development experience.
- Svelte 5: A reactive component framework for building the user interface.
Bug reports & Ideas
Check out everything I’m tracking in this project’s issues.
This is my first public repo, for now and until changes are needed, just create a issue with an appropriate label and a
descriptive message and I will take a look. Any contributions are welcome, issues where I specifically need help are
marked with the contributions welcome label.
Contributing
Prerequisites
- Node.js (version 22 or higher, required by WXT 0.21)
- pnpm (package manager)
Installation
Clone the repository and install dependencies:
git clone https://github.com/Seismix/royalrefresh.git
cd royalrefresh
pnpm install
Development
To start the development server for Chrome (default):
pnpm dev
To start the development server for Firefox:
pnpm dev:firefox
To develop on Android, this builds the Firefox version and runs it on a connected Android device. Make sure ADB is installed, your device is
connected with USB debugging enabled. You can pass additional web-ext run flags after the device ID:
# Basic usage
pnpm dev:android <device-id>
# With custom source directory
pnpm dev:android <device-id> -s ./custom-output
# With additional web-ext flags
pnpm dev:android <device-id> --adb-remove-old-artifacts
Some web-ext run options may not work when targeting Android devices. For example, browser startup options like --start-url are not supported on Android.
Building
To build the extension for chromium browsers:
pnpm build
To build specifically for Firefox:
pnpm build:firefox
Both write to .output/. To produce the store-ready archives instead:
pnpm zip
pnpm zip:firefox
pnpm zip:firefox also emits royalrefresh-<version>-sources.zip, the source
archive AMO requires alongside the add-on. Reviewers rebuild from it, so it has
to install and build on its own. Check that before submitting:
pnpm verify:sources
This unpacks the source archive into a temporary directory, runs
pnpm install --frozen-lockfile && pnpm zip:firefox there, and compares the
SHA-256 of every file in the resulting extension against the one you are about
to ship. It exits non-zero on any mismatch and keeps the work directory for
inspection; pass --keep to keep it after a successful run too. It needs
unzip on PATH.
The zip containers may differ by a few dozen bytes even when every file
matches — that is the DOS timestamp in each entry header, and two back-to-back
builds of identical source differ the same way. Only the file hashes matter.
Testing
Unit and component tests (Vitest, jsdom):
pnpm test:unit
End-to-end tests, which load the built extension into a real browser against a
mocked RoyalRoad:
pnpm test
The canary suite checks the CSS selectors against the live site — this is what
catches a RoyalRoad redesign. It does not run in CI (RoyalRoad’s Cloudflare
challenges GitHub’s runners), so run it locally before a release:
pnpm test:canary
Type checking, add-on linting and formatting:
pnpm check
pnpm lint
pnpm format
Browser Configuration
You can configure browser startup options using web-ext.config.ts files. For more information, see WXT’s
Browser Startup documentation.
For example, to set custom browser binaries or startup URLs, create a web-ext.config.ts file:
import { defineWebExtConfig } from 'wxt';
export default defineWebExtConfig({
startUrls: [
"https://www.royalroad.com/",
"about:addons"
],
binaries: {
firefox: 'firefoxdeveloperedition',
},
});
The file is gitignored, so it stays machine-local — a fresh clone does not have
one. WXT reads the same options from $HOME/web-ext.config.ts as well, as
global defaults for every WXT project, which is handy if you keep several
checkouts of this repo around.
For a full list of options, see the web-ext command reference.
评论