Architecture

Nobook Architecture

Nobook is a highly opinionated desktop wrapper for Facebook, built using Tauri v2. It leverages native OS WebView engines (WebView2 on Windows) to render the Facebook mobile interface (m.facebook.com) while aggressively injecting custom JavaScript and CSS to modify the user experience.

Core Components

1. Tauri Backend (Rust)

The Rust backend is responsible for:

2. Frontend Injector (JavaScript)

Because Nobook does not host its own HTML pages (it loads m.facebook.com directly), all UI and feature logic is dynamically injected at document.readyState === 'loading'. The Rust backend reads raw JS files from app/src/main/res/raw/ and compiles them into a single string during the build process (include_str!). This string is evaluated as the initialization_script of the WebView.

3. Settings Engine

Settings are stored locally in a .nobook_settings.json file in the user’s AppData or HOME directory. When the app launches, Rust parses this JSON and dynamically constructs a window._NOBOOK_FILTERS configuration array. This array is injected directly into the WebView before the MasterObserver initializes.

Data Flow

  1. Launch: desktop.exe starts.
  2. Read Config: Rust reads .nobook_settings.json.
  3. Compile Payload: Rust evaluates flags (e.g., show_suggested: false) and injects the corresponding filter keywords into a single window._NOBOOK_FILTERS configuration payload alongside the core JS modules.
  4. WebView Init: Tauri creates the WebView pointing to Facebook and executes the payload immediately.
  5. DOM Modification: The single Master MutationObserver begins observing the DOM. It checks the text of new nodes against the _NOBOOK_FILTERS array and mutates Facebook’s React tree (hiding elements, styling, intercepting clicks) in a highly-optimized $O(N)$ pass.
  6. IPC Communication: When the user clicks the Custom Settings button, the injected JS communicates with Rust to save new preferences or batch-write to the native log file.