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
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.
2.1 Manifest Configuration Comparison
The table below highlights the key differences between Chrome and Firefox manifest files:
| Feature | Chrome | Firefox |
|---|---|---|
| Background Implementation | Service Worker | Scripts Array |
| Browser ID | Not required | Required (bilifire@ez118) |
| Minimum Version | Not specified | Firefox 107.0+ |
| Options UI | Standard | Browser-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.
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.
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
| Feature | Chrome Testing | Firefox Testing | Notes |
|---|---|---|---|
| Installation | Required | Required | Verify installation process works correctly |
| Background Functions | Required | Required | Test background script functionality |
| UI Rendering | Required | Required | Check for visual differences or styling issues |
| API Communication | Required | Required | Test Bilibili API communication |
| Media Playback | Required | Required | Verify video and live streaming functionality |
| Storage | Required | Required | Test data persistence |
| Notifications | Required | Required | Verify notification display |
| Extension Update | Required | Required | Test version update process |
6. Building and Packaging
BiliScape requires different packaging processes for Chrome and Firefox distributions.
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:
- Monitor changes to Manifest V3 implementation in Firefox
- Watch for updates to the service worker model in Chrome
- Test with beta/dev browser versions to catch compatibility issues early
- 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.