{"id":31720637,"url":"https://github.com/otsobear/chrome2moz","last_synced_at":"2025-10-13T07:02:01.867Z","repository":{"id":318649690,"uuid":"1070876602","full_name":"OtsoBear/chrome2moz","owner":"OtsoBear","description":"chrome extension to firefox extension converter","archived":false,"fork":false,"pushed_at":"2025-10-08T11:05:45.000Z","size":130,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-08T13:11:51.394Z","etag":null,"topics":["chrome","chrome-extensions","firefox","firefox-extensions","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OtsoBear.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-06T14:55:43.000Z","updated_at":"2025-10-08T11:05:48.000Z","dependencies_parsed_at":"2025-10-08T13:12:04.326Z","dependency_job_id":"c55b6908-5581-46bc-a845-d157a929e531","html_url":"https://github.com/OtsoBear/chrome2moz","commit_stats":null,"previous_names":["otsobear/chrome2moz"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/OtsoBear/chrome2moz","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OtsoBear%2Fchrome2moz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OtsoBear%2Fchrome2moz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OtsoBear%2Fchrome2moz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OtsoBear%2Fchrome2moz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OtsoBear","download_url":"https://codeload.github.com/OtsoBear/chrome2moz/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OtsoBear%2Fchrome2moz/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279014005,"owners_count":26085434,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chrome","chrome-extensions","firefox","firefox-extensions","rust"],"created_at":"2025-10-09T03:17:54.006Z","updated_at":"2025-10-13T07:02:01.821Z","avatar_url":"https://github.com/OtsoBear.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Chrome to Firefox Extension Converter\n\nA powerful Rust-based CLI tool that automatically converts Chrome Manifest V3 extensions to Firefox-compatible format. Handles API conversions, manifest transformations, and generates compatibility shims with support for complex patterns like `executeScript` to message-passing conversion.\n\n## Features\n\n- **Automatic API Conversion**: Converts `chrome.*` namespace to `browser.*`\n- **Expanded API Coverage**: 80+ Chrome API mappings including MV3 features\n- **Manifest Transformation**: Adapts Chrome MV3 manifests for Firefox compatibility\n- **Service Worker Handling**: Converts service workers to Firefox event pages\n- **Advanced Transformations**: Automatically converts `executeScript` patterns to message-passing\n- **Smart Analysis**: Detects 90+ types of incompatibilities\n- **Intelligent Shims**: Auto-generates 10+ compatibility shims based on API usage\n- **MV3 API Support**: Handles `storage.session`, `sidePanel`, `userScripts`, and more\n- **Legacy API Support**: Maps deprecated Chrome APIs to modern equivalents\n- **XPI Packaging**: Creates ready-to-install Firefox extension packages\n- **Detailed Reports**: Comprehensive conversion reports with statistics\n- **Batch Processing**: Handles multiple files efficiently\n\n## Quick Start\n\n### Installation\n\n```bash\n# Clone the repository\ngit clone https://github.com/OtsoBear/chrome-to-firefox.git\ncd chrome-to-firefox\n\n# Build the project\ncargo build --release\n```\n\n### Your First Conversion\n\n```bash\n# Analyze your extension first\ncargo run -- analyze -i ./path/to/chrome-extension\n\n# Convert to Firefox format\ncargo run -- convert -i ./path/to/chrome-extension -o ./output --report\n\n# Check the results\ncat output.md\n```\n\n### Try the Example\n\n```bash\n# Convert the included test extension\ncargo run -- convert -i ./LatexToCalc -o ./converted-output --report\n\n# Expected output:\n# Conversion completed successfully!\n# Files modified: 5\n# Files added: 3 (compatibility shims)\n# Total changes: 73\n```\n\n## What Gets Converted\n\n### JavaScript Transformations\n\n**API Namespace Conversion:**\n```javascript\n// Before\nchrome.storage.sync.get(\"key\", callback);\nchrome.tabs.query({active: true}, callback);\n\n// After\nbrowser.storage.sync.get(\"key\", callback);\nbrowser.tabs.query({active: true}, callback);\n```\n\n**Browser Polyfill Injection:**\n```javascript\n// Added automatically to all JavaScript files\nif (typeof browser === 'undefined') {\n  var browser = chrome;\n}\n```\n\n**executeScript to Message Passing** (Advanced):\n```javascript\n// Before (Chrome pattern)\nchrome.scripting.executeScript({\n    target: { tabId: activeTab.id },\n    function: (reqId) =\u003e {\n        const result = myFunction(reqId);  // Function from content script\n        chrome.runtime.sendMessage({type: \"RESULT\", result});\n    },\n    args: [requestId]\n});\n\n// After (Firefox-compatible)\n// In background.js:\nbrowser.tabs.sendMessage(activeTab.id, {\n    type: 'EXECUTE_SCRIPT_REQUEST_265',\n    args: [requestId]\n});\n\n// In content.js (auto-generated listener):\nbrowser.runtime.onMessage.addListener((request, sender, sendResponse) =\u003e {\n    if (request.type === 'EXECUTE_SCRIPT_REQUEST_265') {\n        const [reqId] = request.args;\n        const result = myFunction(reqId);\n        browser.runtime.sendMessage({type: \"RESULT\", result});\n        return true;\n    }\n});\n```\n\n### Manifest Transformations\n\n**Firefox-Specific Settings:**\n```json\n{\n  \"browser_specific_settings\": {\n    \"gecko\": {\n      \"id\": \"extension@converted.extension\",\n      \"strict_min_version\": \"121.0\"\n    }\n  }\n}\n```\n\n**Background Scripts:**\n```json\n{\n  \"background\": {\n    \"service_worker\": \"background.js\",\n    \"scripts\": [\"background.js\"],\n    \"persistent\": false\n  }\n}\n```\n\n**Permission Restructuring:**\n```json\n{\n  \"permissions\": [\"storage\", \"tabs\"],\n  \"host_permissions\": [\"https://example.com/*\"]\n}\n```\n\n## Usage\n\n### Command Reference\n\n#### Analyze Command\nInspect an extension without converting:\n\n```bash\ncargo run -- analyze -i ./extension-directory\n```\n\nOutput shows:\n- All detected incompatibilities\n- Severity levels (Blocker, Major, Minor, Info)\n- Auto-fixable issues\n- Manual action items\n\n#### Convert Command\n\nConvert an extension to Firefox format:\n\n```bash\ncargo run -- convert -i ./chrome-extension -o ./firefox-version --report\n\nOptions:\n  -i, --input \u003cPATH\u003e     Input Chrome extension directory\n  -o, --output \u003cPATH\u003e    Output directory for Firefox version\n  -r, --report           Generate detailed conversion report\n```\n\n#### Chrome-Only APIs Command\n\nList WebExtension APIs that currently exist only in Chrome:\n\n```bash\ncargo run -- chrome-only-apis\n```\n\nThis command reaches out to MDN's `browser-compat-data` repository using the GitHub\nAPI (no clone required) and reports every feature where Chrome has support but Firefox\ndoes not. Use it to quickly identify compatibility gaps before starting a port. The\nreport now highlights how many of the detected APIs already have shims or detection\nlogic in `src/parser/javascript.rs`, so you can spot remaining work at a glance.\n\nExample summary section:\n\n```text\nSummary:\n  Total Chrome-only APIs found: 42\n  Implemented (matches parser/javascript.rs): 6\n  Not yet implemented: 36\n  Known chrome-only prefixes tracked: 14\n  Known prefixes missing from MDN dataset: 2\n    Missing prefixes:\n      - chrome.downloads.acceptDanger\n      - chrome.downloads.setShelfEnabled\n```\n\n### Output Structure\n\nAfter conversion:\n\n```\noutput/\n├── manifest.json              # Transformed for Firefox\n├── background.js              # chrome.* → browser.*\n├── content.js                 # With auto-generated listeners\n├── popup.js                   # Converted\n└── [other extension files]\n\noutput.xpi                     # Ready-to-install Firefox package\noutput.md                      # Detailed conversion report\n```\n\n### Conversion Report\n\nThe report includes:\n\n```markdown\n## Summary\n- Extension: LatexToCalc v2.0.1\n- Conversion Status: ✅ Success\n- Files Modified: 5\n- Total Changes: 73\n- Chrome API Calls Converted: 57\n- Callback→Promise Conversions: 10\n\n## Transformations\n- background.js: 36 changes\n  - ✓ Converted chrome → browser (8)\n  - ✓ Converted executeScript to message passing (3)\n  - ✓ Added browser polyfill\n```\n\n## Testing in Firefox\n\n### Method 1: Temporary Add-on\n1. Open Firefox\n2. Go to `about:debugging#/runtime/this-firefox`\n3. Click \"Load Temporary Add-on\"\n4. Select `output/manifest.json`\n\n### Method 2: Install XPI\n1. Open Firefox\n2. Go to `about:addons`\n3. Click gear icon → \"Install Add-on From File\"\n4. Select `output.xpi`\n\n### Debugging\nCheck the Browser Console (Ctrl+Shift+J) for any errors.\n\n## Key Transformations\n\n### 1. Chrome API → Browser API\n- All `chrome.*` calls converted to `browser.*`\n- Maintains backward compatibility with Chrome\n\n### 2. Manifest V3 → Firefox MV3\n- Adds `browser_specific_settings.gecko.id`\n- Converts service workers to event pages\n- Restructures permissions\n\n### 3. executeScript Isolation Handling\n- Detects `scripting.executeScript` with function references\n- Extracts function code and variables\n- Generates message passing architecture\n- Creates listeners in content scripts\n\n### 4. declarativeNetRequest → webRequest Conversion\nChrome's declarative network request API is automatically converted to Firefox's imperative webRequest:\n\n```javascript\n// Chrome DNR rule (declarative)\nchrome.declarativeNetRequest.updateDynamicRules({\n    addRules: [{\n        id: 1,\n        priority: 1,\n        action: { type: 'block' },\n        condition: {\n            urlFilter: '||ads.example.com/*',\n            resourceTypes: ['script', 'image']\n        }\n    }]\n});\n\n// Converted to Firefox webRequest (imperative)\nbrowser.webRequest.onBeforeRequest.addListener(\n    (details) =\u003e {\n        if (matchesCondition(details)) {\n            return { cancel: true };\n        }\n    },\n    { urls: ['*://ads.example.com/*'], types: ['script', 'image'] },\n    ['blocking']\n);\n```\n\n**Supported DNR Actions:**\n- **Block**: Converts to `onBeforeRequest` with `{cancel: true}`\n- **Redirect**: Converts to `onBeforeRequest` with `{redirectUrl: newUrl}`\n  - Supports URL rewrites, regex substitution, URL transformations\n- **ModifyHeaders**: Converts to `onBeforeSendHeaders`/`onHeadersReceived`\n  - Supports request and response header modifications\n- **UpgradeScheme**: HTTP→HTTPS via redirect\n\n**Rule Features:**\n- Domain and initiator filtering\n- Resource type filtering\n- URL pattern conversion\n- Dynamic and session rule support\n- Debug events emulation\n\n### 5. Compatibility Shims\nGenerated shims provide extensive cross-browser support:\n\n**Core Shims:**\n- `browser-polyfill.js`: Namespace compatibility\n- `action-compat.js`: Action API bridging\n- `promise-wrapper.js`: Callback-to-promise helpers\n\n**MV3 API Shims:**\n- `storage-session-compat.js`: Native in Firefox 115+, in-memory polyfill for older versions\n- `sidepanel-compat.js`: Maps `sidePanel` to Firefox's `sidebarAction`\n- `declarative-net-request-stub.js`: Converts DNR rules to `webRequest` listeners automatically\n- `user-scripts-compat.js`: Translates `userScripts` API\n\n**Legacy API Shims:**\n- `tabs-windows-compat.js`: Maps deprecated `tabs.getSelected`, `tabs.getAllInWindow`\n- `runtime-compat.js`: Stubs `runtime.getPackageDirectoryEntry`\n\n**Optional Shims:**\n- `downloads-compat.js`: Handles Chrome-specific download features\n- `privacy-stub.js`: Stubs `chrome.privacy` API\n- `notifications-compat.js`: Adapts notification options for Firefox\n\n## ⚠️ Known Limitations\n\n### Chrome-Only APIs\nSome Chrome features have no or limited Firefox equivalent:\n\n**Not Available (Blockers):**\n- `chrome.offscreen.*` - No equivalent\n- `chrome.declarativeContent.*` - No equivalent\n- `chrome.tabGroups.*` - No equivalent\n\n**Partial Support (Shims Provided):**\n- `chrome.sidePanel.*` - Maps to Firefox's `sidebarAction` (different UI)\n- `chrome.declarativeNetRequest.*` - Automatically converted to `webRequest` listeners at runtime\n  - Supports: block, redirect, modifyHeaders, upgradeScheme rules\n  - Converts dynamic/session rules to imperative callbacks\n  - Note: Static rulesets and allow rules have limited support\n- `chrome.userScripts.*` - Maps to Firefox's different API structure\n- `chrome.storage.session` - In-memory polyfill (data not persisted)\n- `chrome.privacy.*` - Stubbed as read-only (use Firefox preferences)\n\n**Legacy APIs (Shims Provided):**\n- `tabs.getSelected` / `tabs.getAllInWindow` - Mapped to modern `tabs.query`\n- `runtime.getPackageDirectoryEntry` - Stubbed with guidance\n\nThe tool automatically applies shims where possible and flags blockers in the report.\n\n### Service Workers vs Event Pages\nChrome uses service workers, Firefox uses event pages:\n- Different lifecycle management\n- No `importScripts()` in Firefox\n- Converted to `background.scripts` array\n\n### Host Permissions\nFirefox treats `host_permissions` as optional (user can deny), while Chrome grants them at install time.\n\n## Development\n\n### Building\n\n```bash\n# Debug build\ncargo build\n\n# Release build (optimized)\ncargo build --release\n\n# Run tests\ncargo test\n\n# Code quality\ncargo fmt\ncargo clippy\n```\n\n### Project Structure\n\n```\nsrc/\n├── main.rs              # CLI entry point\n├── lib.rs               # Library root\n├── models/              # Data structures\n├── parser/              # Manifest \u0026 JS parsing\n├── analyzer/            # Incompatibility detection\n├── transformer/         # Code transformation\n│   ├── manifest.rs      # Manifest transformer\n│   └── javascript.rs    # JS transformer (executeScript conversion)\n├── packager/            # XPI packaging\n├── validator/           # Output validation\n└── report/             # Report generation\n```\n\n### Running with Cargo\n\n```bash\n# Analyze\ncargo run -- analyze -i ./LatexToCalc\n\n# Convert\ncargo run -- convert -i ./LatexToCalc -o ./output --report\n\n# Use release build (faster)\n./target/release/chrome-to-firefox convert -i ./extension -o ./output\n```\n\n## Documentation\n\n- **[ARCHITECTURE.md](ARCHITECTURE.md)** - Technical architecture and implementation details\n- **Conversion Reports** - Generated with `--report` flag\n- **In-code Documentation** - Run `cargo doc --open`\n\n## Contributing\n\nContributions are welcome! Areas for contribution:\n\n- Additional API mappings\n- More test cases\n- Documentation improvements\n- Bug fixes\n- New features\n\nSee the LatexToCalc extension as a reference for testing.\n\n## Troubleshooting\n\n### Build Errors\n```bash\ncargo clean\ncargo build --release\n```\n\n### Conversion Issues\n1. Check the error message\n2. Review the conversion report\n3. Ensure input is valid Chrome MV3\n4. Check file permissions\n\n### Extension Doesn't Work\n1. Open Browser Console (Ctrl+Shift+J)\n2. Check for JavaScript errors\n3. Review manifest in `about:debugging`\n4. Check permissions are granted\n\n## License\n\nThis project is licensed under the MIT License.\n\n## Acknowledgments\n\n- Built with Rust\n- Test extension: [LatexToCalc](LatexToCalc/)\n- Inspired by the need for cross-browser extension compatibility\n\n## Support\n\n- [Report a bug](https://github.com/OtsoBear/chrome-to-firefox/issues)\n- [Request a feature](https://github.com/OtsoBear/chrome-to-firefox/issues)\n- [Read the architecture docs](./ARCHITECTURE.md)\n\n---\n\n**Status**: Production-ready  \n**Version**: 0.1.0  \n**Last Updated**: October 2025\n\nMade with care for the open web\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fotsobear%2Fchrome2moz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fotsobear%2Fchrome2moz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fotsobear%2Fchrome2moz/lists"}