A powerful command-line tool to convert browser extensions to userscripts with support for downloading from web stores.
npm install -g extension-to-userscriptOr run directly:
npx extension-to-userscript# Convert from Chrome Web Store
ext2us convert https://chrome.google.com/webstore/detail/extension-id
# Convert local extension folder
ext2us convert ./my-extension/
# Convert CRX/XPI/ZIP file
ext2us convert extension.crx -o my-script.user.js
# Download only (no conversion)
ext2us download extension-id -s chromeConvert an extension to userscript from various sources:
- Web Store URL:
https://chrome.google.com/webstore/detail/... - Extension ID:
abcdefghijklmnopqrstuvwxyz123456 - Local Archive:
extension.crx,extension.xpi,extension.zip - Local Directory:
./extension-folder/
-o, --output <file>- Output file path (default:extension.user.js)-s, --store <type>- Web store type:chromeorfirefox(default:chrome)-t, --target <type>- Build target:userscriptorvanilla(default:userscript)-m, --minify- Minify output (default:true)--no-minify- Disable minification--temp-dir <dir>- Custom temporary directory--keep-temp- Keep temporary files after conversion-v, --verbose- Verbose output with detailed information
# Convert Chrome extension with custom output
ext2us convert "https://chrome.google.com/webstore/detail/name/abcd..." -o my-script.user.js
# Convert Firefox addon
ext2us convert ublock-origin -s firefox --verbose
# Convert local extension without minification
ext2us convert ./extension-folder/ --no-minify
# Convert to vanilla JS target
ext2us convert extension.crx -t vanilla -o extension.jsDownload extension from web store without converting:
-o, --output <file>- Output file path (auto-generated if not specified)-s, --store <type>- Web store type:chromeorfirefox(default:chrome)
# Download Chrome extension
ext2us download extension-id
# Download Firefox addon
ext2us download addon-name -s firefox -o addon.xpi
# Download from URL
ext2us download "https://addons.mozilla.org/addon/name/"- Chrome Web Store: URLs or extension IDs
- Firefox Add-ons: URLs or addon names/IDs
- Archive Files:
.crx,.xpi,.zip - Directories: Local extension folders with
manifest.json
- Userscript (default):
.user.jsfiles for Tampermonkey, Greasemonkey, etc. - Vanilla JS: Standalone
.jsfiles using browser APIs (limited functionality)
- Chrome Web Store: Direct download via CRX URLs
- Firefox Add-ons: API integration for latest versions
- Progress tracking: Real-time download progress
- Validation: File type and size validation
- CRX Support: Chrome extension format with header parsing
- XPI Support: Firefox addon format
- ZIP Support: Generic ZIP archives
- Security: Path traversal protection
- Validation: Manifest.json verification
- Content Scripts: Full support with proper timing
- Background Scripts: Auto-execution in polyfilled environment
- Options Pages: Modal iframe implementation
- Popup Pages: Modal iframe implementation
- Assets: Automatic inlining and resource management
- Permissions: Smart grant detection and metadata generation
- Icons: Embedded in userscript metadata
- Minification: Prettier-based code formatting (can be disabled)
- Error Handling: Comprehensive error reporting
- Validation: Input and output validation
- Cleanup: Automatic temporary file management
Use -v or --verbose for detailed information:
ext2us convert extension.crx -vOutput includes:
- Extension metadata
- File processing details
- Conversion summary
- Performance metrics
ext2us convert extension.crx --temp-dir /custom/temp --keep-tempProcess multiple extensions:
ext2us convert ext1.crx -o script1.user.js
ext2us convert ext2.crx -o script2.user.js-
"Extension not found"
- Verify the extension ID or URL
- Check if the extension is publicly available
- Try using the full web store URL
-
"Archive extraction failed"
- Ensure the file is a valid extension archive
- Check file permissions
- Verify the file isn't corrupted
-
"Manifest parsing error"
- Ensure the extension contains a valid manifest.json
- Check for JSON syntax errors
- Verify required manifest fields are present
-
"Download failed"
- Check internet connection
- Verify the extension is still available
- Try again later if web store is temporarily unavailable
# Maximum verbosity
ext2us convert extension.crx -v --keep-temp
# Check temporary files
ls /tmp/ext2us-*- Manifest V2: Full support
- Manifest V3: Basic support (limitations apply)
Generated userscripts work with:
- Tampermonkey (Chrome, Firefox, Safari, Edge)
- Greasemonkey (Firefox)
- Violentmonkey (Chrome, Firefox, Edge)
The converter provides polyfills for:
chrome.storage(local, sync, managed)chrome.runtime(sendMessage, onMessage, getURL, getManifest)chrome.tabs(query, create, sendMessage)chrome.notifications(create, clear, onClicked)chrome.contextMenus(create, remove, onClicked)- And more...
- Service workers (MV3) have limited support
- Some privileged APIs cannot be polyfilled
- Cross-origin requests require proper @connect grants
- Vanilla target has significant CORS limitations
src/cli/
├── index.js # Main CLI entry point
├── inputValidator.js # Input type detection and validation
├── storeDownloader.js # Web store download functionality
├── archiveExtractor.js # Archive extraction (CRX/XPI/ZIP)
├── workspaceManager.js # Temporary directory management
├── extensionConverter.js # Conversion orchestration
└── downloadExt.js # CRX URL generation
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Submit a pull request
ISC License - see LICENSE file for details