Servarr Auto Search Browser Extension

repository·master·Indexed 41 days ago

https://github.com/trossr32/sonarr-radarr-lidarr-autosearch-browser-extension

A browser extension for Chromium and Firefox that integrates Sonarr, Radarr, Lidarr, and Readarr into the browsing workflow. It features URL-based search triggering, right-click context menu integration for selected text, and direct search links injected into media websites like IMDb, TVDb, TMDb, and Trakt.

Tokens
3.2K
Snippets
9
Records
20
Agent score
2%

What's inside Servarr Auto Search

  1. Overview of Servarr Auto Search extension

    master

    Servarr Auto Search is a browser extension for Chromium and Firefox designed to streamline searching within Servarr instances (Sonarr, Radarr, Lidarr, and Readarr). It provides three main functionalities:

    1. URL-based Search Triggering: Automatically populates the search field and triggers a search on a Servarr instance when text is appended to the end of a standard search URL. For example, appending /fringe to http://my.sonarr.domain:7357/add/new will automatically search for "fringe".
    2. Context Menu Integration: Adds a right-click context menu for selected text, allowing users to perform a direct search in Sonarr, Radarr, Lidarr, or Readarr in a new tab.
    3. Direct Search Links on External Sites: Injects Servarr icons onto various media-related websites (such as IMDb, TVDb, TMDb, Trakt, etc.) to act as direct search links.

    The extension can be toggled via the popup or customized through the settings page, where individual context menu items can be disabled.

  2. Understand the extension's core functionality

    master

    The Servarr Autosearch extension streamlines searching across user-hosted Servarr applications (Sonarr, Radarr, Lidarr, and Readarr) through several key features:

    • Auto-prefilling: Automatically fills Servarr search pages when navigating to URLs containing /add/new/<term> or similar patterns.
    • Context Menu: Adds search items to the browser's right-click menu for selected text.
    • Site Integration: Injects search icons/links into supported third-party media sites (e.g., IMDb, TMDb, Trakt, Wikipedia, etc.).
    • Configuration UI: An options page to manage base URLs and API keys.
    • Backup & Restore: Allows exporting and importing user settings via schema-versioned JSON files.
  3. Understand the background and runtime architecture

    master

    The extension's logic is distributed across several components:

    ComponentRole
    Content scriptsInjected either declaratively via the manifest on listed integration domains, or programmatically from the background for user-configured Servarr domains.
    eventPage.chrome.jsThe MV3 service worker responsible for message routing, context menu handling, storage propagation, and programmatic injection.
    eventPage.jsThe Firefox MV2 background script equivalent.
    core.jsShared helpers for settings access, API version probing, URL building, and a browser polyfill.
    options.jsHandles the Options UI assembly and logic (settings, site management, backup/restore).
    popup.jsManages the popup UI for enabling/disabling the extension and quick settings access.
  4. Get started with Servarr Auto Search

    master

    To use the extension, install it from your browser's respective store:

    After installation, navigate to the extension's options page to configure your settings.

    Note: The extension defaults to settings for the latest versions of Sonarr and Radarr. If you are using v2.0, refer to the Advanced settings tab for specific guidance.

  5. Configure extension settings

    master

    The extension requires configuration of your Servarr instances to function correctly:

    1. Instance URLs: Fill out the URL fields for each instance (e.g., http://my.servarr.domain:7357).
    2. API Keys: If you provide the API keys for each instance, the extension will automatically populate the Advanced settings based on your instance version.
    3. Permissions: You must grant the extension permission to run on the domains of your Servarr instances. This is necessary for the extension to populate the search field on those sites.
  6. Backup and restore extension settings

    master

    Settings management is handled via the "Backup & restore" tab in the Options menu.

    Backup

    Click "Download backup" to download a pretty-printed JSON file using an envelope format. The envelope includes:

    • type: "servarr-autosearch-settings"
    • schemaVersion: (e.g., 1)
    • exportedAt: ISO timestamp
    • appVersion: Extension version
    • data: Sanitized settings payload (internal fields prefixed with _ or __ are stripped).

    Restore

    1. Choose a previously saved JSON file (supports both the new envelope format and legacy plain JSON).
    2. Merge vs Replace:
      • By default, the extension performs a deep merge (objects are merged, arrays are replaced).
      • Check "Replace existing settings instead of merging" to overwrite all current settings with the file contents.
    3. Preview: Click "Preview changes" to inspect a diff of added, removed, or changed paths before applying.
    4. Apply: Click "Restore" to parse and validate the file (checking for config, sites[], and integrations[]).

    Reset

    Click "Reset settings" and confirm via the prompt to revert to built-in defaults.

    Note: All operations are performed locally; no data is transmitted over the network.

  7. Run Playwright integration tests

    master

    Site integration tests are located in the tests/playwright directory. These tests require the dist directory to be populated with a recent build. Run the following sequence from the root directory:

    npm i
    # npm i grunt -g    # if grunt isn't already installed uncomment
    grunt playwright
    cd tests/playwright
    npm i
    npx playwright install --with-deps chromium
    npx playwright test
  8. Build the extension from source

    master

    To perform a clean build of the extension, use npm ci to install dependencies followed by grunt release. This process generates reproducible build artifacts in the dist/ directory.

    • dist/chromium: An MV3 build using eventPage.chrome.js as the service worker and background script bundle.
    • dist/firefox: An MV2 build using background.scripts.
    # Use PowerShell equivalent if on Windows
    npm ci
    grant release