Skip to content

Cross-Browser Support

Relevant source files

The following files were used as context for generating this wiki page:

This document details how BiliScape implements cross-browser compatibility between Google Chrome and Mozilla Firefox browsers. It covers manifest differences, platform-specific adaptations, and compatibility considerations for developers working on the extension.

For information about the high-level architecture of the extension, see Extension Architecture.

1. Manifest File Differences

BiliScape maintains separate manifest files for Chrome and Firefox to accommodate browser-specific implementation requirements while maintaining the same functionality.

1.1 Chrome Manifest Structure

The Chrome manifest uses the standard Manifest V3 structure with a service worker for the background script.

Key Chrome-specific elements:

  • Background script defined as a service worker
  • No browser-specific settings required
┌────────────────────────┐
│ manifest.json (Chrome) │
├────────────────────────┤
│ name: "BiliScape"      │
│ version: "3.3.3"       │
│ manifest_version: 3    │
│                        │
│ background: {          │
│   service_worker:      │
│   "./js/background.js" │
│ }                      │
│                        │
│ options_ui: {          │
│   page: "./options.html"│
│ }                      │
└────────────────────────┘

Sources: manifest.json:1-33

1.2 Firefox Manifest Structure

The Firefox manifest requires additional configuration to ensure compatibility with Firefox's implementation of Manifest V3.

Key Firefox-specific elements:

  • Background scripts defined as an array
  • Browser-specific settings with gecko ID
  • Minimum Firefox version requirement (107.0)
  • Browser styling flag for options UI
mermaid Diagram

Sources: manifest_firefox.json:1-42

2. Key Differences Between Browsers

This section outlines the specific differences in implementation between Chrome and Firefox versions of BiliScape.

mermaid Diagram

2.1 Manifest Configuration Comparison

The table below highlights the key differences between Chrome and Firefox manifest files:

FeatureChromeFirefox
Background ImplementationService WorkerScripts Array
Browser IDNot requiredRequired (bilifire@ez118)
Minimum VersionNot specifiedFirefox 107.0+
Options UIStandardBrowser-styled

Sources: manifest.json:1-33, manifest_firefox.json:1-42

2.2 Background Script Implementation

The most significant difference is how background scripts are defined:

  • Chrome: Uses service worker architecture

    json
    "background": {
        "service_worker": "./js/background.js"
    }
  • Firefox: Uses traditional scripts array

    json
    "background": {
        "scripts": [
            "./js/background.js"
        ]
    }

This distinction is necessary because Firefox's implementation of Manifest V3 still supports the scripts array approach, while Chrome exclusively uses the service worker model.

Sources: manifest.json:27-29, manifest_firefox.json:27-31

3. Browser API Compatibility

BiliScape needs to handle differences in browser extension APIs between Chrome and Firefox.

mermaid Diagram

3.1 API Naming Conventions

Firefox uses the standardized browser.* namespace for WebExtension APIs, while Chrome uses the chrome.* namespace. BiliScape must account for these different namespaces when using extension APIs.

3.2 Promise-Based vs. Callback-Based APIs

Firefox's WebExtension APIs are promise-based, while Chrome's are traditionally callback-based. The extension needs to handle these different patterns:

  • Firefox: Returns promises that can be used with async/await
  • Chrome: Uses callback functions for asynchronous operations

4. Permissions Handling

Both versions of BiliScape request identical permissions, which is a positive aspect for cross-browser compatibility.

mermaid Diagram

Sources: manifest.json:10-23, manifest_firefox.json:10-23

5. Testing and Verification

For proper cross-browser support, BiliScape should be tested in both Chrome and Firefox environments to ensure consistent behavior.

5.1 Testing Checklist

FeatureChrome TestingFirefox TestingNotes
InstallationRequiredRequiredVerify installation process works correctly
Background FunctionsRequiredRequiredTest background script functionality
UI RenderingRequiredRequiredCheck for visual differences or styling issues
API CommunicationRequiredRequiredTest Bilibili API communication
Media PlaybackRequiredRequiredVerify video and live streaming functionality
StorageRequiredRequiredTest data persistence
NotificationsRequiredRequiredVerify notification display
Extension UpdateRequiredRequiredTest version update process

6. Building and Packaging

BiliScape requires different packaging processes for Chrome and Firefox distributions.

mermaid Diagram

6.1 Chrome Build Process

For Chrome distribution, the standard manifest.json file is used without modification.

6.2 Firefox Build Process

For Firefox distribution, the manifest_firefox.json file must be renamed to manifest.json before packaging.

7. Browser-Specific Considerations

7.1 Firefox

  • Requires gecko ID (bilifire@ez118) for proper identification
  • Minimum Firefox version requirement (107.0)
  • Uses traditional background scripts array instead of service worker

7.2 Chrome

  • Uses service worker for background script execution
  • No specific browser ID required
  • May have different performance characteristics for background tasks

Sources: manifest.json:1-33, manifest_firefox.json:1-42

8. Future Compatibility Considerations

As browsers continue to evolve their extension APIs, BiliScape will need to maintain compatibility with future versions of both Chrome and Firefox:

  1. Monitor changes to Manifest V3 implementation in Firefox
  2. Watch for updates to the service worker model in Chrome
  3. Test with beta/dev browser versions to catch compatibility issues early
  4. Maintain separate manifest files for each browser platform

By following these guidelines, BiliScape can maintain cross-browser compatibility while delivering a consistent user experience across both Chrome and Firefox browsers.