Skip to content

Run community plugins as sandboxed web pages - #33

Merged
CodySimonds65 merged 50 commits into
feature/runelite-pluginsfrom
feature/web-plugins
Oct 3, 2026
Merged

CodySimonds65 merged 50 commits into
feature/runelite-pluginsfrom
feature/web-plugins

Conversation

@CodySimonds65

Copy link
Copy Markdown
Owner

Summary

Part 2 of the plugin system: the runtime for community plugins. It merges into part 1 (#31), not main.

A plugin is a folder with plugin.json plus web files (HTML, JavaScript, CSS). FourFold runs it as a sandboxed page in the plugin strip, and the page talks to the app only through a small window.fourfold library. In this part plugins load only from a local dev folder, for plugin authors. The hub that lets everyone install reviewed plugins is part 3.

  • Developer mode: a switch at the bottom of the plugin list. It loads every folder in %LOCALAPPDATA%\FourFoldAccountManager\dev-plugins, each with a DEV badge and a "Can contact" line.
    • Saving a file reloads the plugin. Right-click → Inspect opens the developer tools.
    • A folder whose plugin.json breaks a rule is listed with the reason.
    • With developer mode off, no plugin browser is started and nothing changes for existing users.
  • What a plugin can read: the account list (id, label, in-game name, open or not), XP and stats for open accounts, and the timer.
    • Never a saved login, a password, a game page, a cookie or a file.
    • An account with no ranking name has no in-game name for plugins, because that name would be the saved login.
  • What a plugin can do:
    • Fetch from sites it declared in plugin.json. FourFold makes the request itself: https only, public addresses only, no cookies.
    • Keep up to 256 KB of its own settings.
    • Open an https link in the user's browser.
    • Fill data cards.
  • Plugin cards: rows of label and value with an optional progress bar, drawn by FourFold beside the built-in cards: over the game, floating, and in the Overlays panel.
    • They are listed as "Card name (plugin short label)", so a plugin's card can't pass for a built-in one.
    • A card dims when its plugin isn't running.
  • Author guide and samples: PLUGIN_AUTHORS.md documents plugin.json, the API, the sandbox and every limit. samples/goal-tracker is a working plugin with a card. samples/sandbox-check tries the things a plugin must not be able to do and reports PASS or FAIL.

The sandbox

  • Own browser: all plugins share one WebView2 environment with its own data folder, separate from the game clients. Each plugin gets its own address, https://<id>.fourfoldplugin/.
  • Own files only: FourFold serves the plugin's files itself, with a content security policy on every response. Scripts run only from the plugin's own files: no inline script, no eval.
  • Blocked: workers of any kind, WebRTC, navigation away, new windows, downloads, device permissions, screen capture, script dialogs, sign-in prompts, external URI schemes, window.close() and window.print().
  • Network: page requests go only to declared sites. Local names and addresses are refused everywhere.
  • Floods: a plugin that floods the app is stopped and shows a Reload button. The thresholds are in the author guide.
  • Other caps: 32 calls in flight, 120 storage writes a minute, 60 fetches a minute, 8 MB per served file, 5 MB of browser storage.

Behavior to know about

  • New saved settings: pluginDeveloperMode, and a pluginCard id on overlay card placements. The previous release reads a newer settings file without failing; it ignores plugin cards.
  • F5 in a plugin panel reloads that plugin. Browser keys stay on in plugin pages, as in the game panels.
  • The close lock uses reflection. The WebView2 control closes its parent window on window.close(), so the host detaches that handler from the control's private members. If a WebView2 SDK update renames them, plugins refuse to start until the lock is re-checked.
  • Opening the plugin list from a closed panel now saves the panel as open.
  • Fetches identify themselves: FourFold-run fetches send User-Agent: FourFold-Plugin/1 unless the plugin sets its own.
  • Known limits, left for part 3:
    • A page can leak a host name through DNS prefetch.
    • File pickers need only an OS dialog.
    • A plugin's panel has no host-drawn header.
    • The click requirement for opening a link is enforced only in the injected library.

Test plan

  • dotnet build FourFoldAccountManager.sln -c Debug: 0 warnings, 0 errors.
  • Core tests (189) and Desktop tests (27) pass. New tests cover the manifest rules, the network policy, file serving, storage, the fetch, the API boundary, saved plugin cards and the plugin order.
  • Leaderboard tests: 32 pass. The 8 that fail need Docker and were not re-checked here.
  • Developer mode is off by default. Turning it on lists the two samples with a DEV badge; turning it off removes them.
  • Goal tracker: setting a goal shows progress, and the goal survives a restart. Typing a goal isn't interrupted by an XP update.
  • The Goal card, switched on in the Overlays panel, shows over the game with a progress bar, can float, and keeps updating while the strip is hidden.
  • A card with a long value and a long summary is trimmed with an ellipsis; the built-in cards' switches look unchanged.
  • Sandbox check: every line says PASS, no dialog appears, and FourFold stays open. "Open example.com" opens the browser; "Navigate away" does nothing.
  • "Flood FourFold" stops the plugin with a Reload button, the app stays responsive, and Reload brings it back. Its card dims, then un-dims.
  • Saving a plugin file reloads it within about a second. Breaking plugin.json shows the reason; fixing it loads the plugin again.
  • Switching a sample off removes its icon and cards; switching it on restores them. Dragging its icon reorders it across a restart.
  • Pop out tools: the plugin's panel moves to the tools window and keeps working.
  • F5 in a focused plugin panel reloads the plugin; the game panels' F5 is unchanged.
  • Tab never moves focus into an invisible plugin page.
  • With developer mode on, the app is usable at once at start, before plugin icons appear.
  • From a fresh launch with developer mode off, no plugin browser process is running.

Review notes: every task was reviewed on its own and the branch was reviewed as a whole. The WebView2 behaviour was checked with throwaway harnesses against a real WebView2, not inside FourFold, so the manual checks above are the first run in the app. The last commit (f65b28e, five small edits) was not independently reviewed.

@CodySimonds65
CodySimonds65 merged commit 38b0658 into feature/runelite-plugins Oct 3, 2026
@CodySimonds65
CodySimonds65 deleted the feature/web-plugins branch October 4, 2026 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant