Skip to content

Commit 91d1679

Browse files
committed
feat: Add Firefox cross-browser compatibility
- Added browser API polyfills to all JavaScript files (background.js, content.js, popup.js) - Replaced all chrome.* API calls with browser.* for cross-browser compatibility - Created separate manifests for Chrome (MV3) and Firefox (MV2) - manifest.json: Chrome version with service_worker - manifest.firefox.json: Firefox version with background scripts - manifest.chrome.json: Backup of Chrome manifest - Added switch-manifest.sh script to easily swap between browser manifests - Added build.sh script for creating distribution packages - Updated README.md with Firefox installation instructions and manifest switching guide - Created BROWSER_COMPATIBILITY.md with technical documentation - Extension now fully supports both Chrome and Firefox with single codebase Technical details: - Chrome: Manifest V3 with service_worker - Firefox: Manifest V2 with background.scripts (more stable) - Browser API polyfill ensures code works identically across browsers
1 parent 66f6f9f commit 91d1679

File tree

9 files changed

+486
-31
lines changed

9 files changed

+486
-31
lines changed

BROWSER_COMPATIBILITY.md

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
# CrowdAssist - Browser Compatibility
2+
3+
CrowdAssist is compatible with both **Chrome** and **Firefox** using a single codebase with separate manifest files for each browser.
4+
5+
## Quick Start
6+
7+
### Chrome / Chromium / Edge / Brave
8+
9+
1. Ensure Chrome manifest is active:
10+
```bash
11+
./switch-manifest.sh chrome
12+
```
13+
2. Open `chrome://extensions/` (or equivalent)
14+
3. Enable "Developer mode"
15+
4. Click "Load unpacked"
16+
5. Select the `extension/` folder
17+
18+
### Firefox
19+
20+
1. Switch to Firefox manifest:
21+
```bash
22+
./switch-manifest.sh firefox
23+
```
24+
2. Open `about:debugging#/runtime/this-firefox`
25+
3. Click "Load Temporary Add-on"
26+
4. Navigate to the `extension/` folder and select `manifest.json`
27+
28+
> **Key Point:** Firefox always reads the file named `manifest.json`, which is why we use a switch script to swap between the Chrome and Firefox versions.
29+
30+
## Why Two Manifests?
31+
32+
While both browsers support web extensions, they have different manifest requirements:
33+
34+
| Feature | Chrome (MV3) | Firefox (MV2) |
35+
|---------|-------------|---------------|
36+
| Manifest Version | 3 | 2 (more stable) |
37+
| Background Script | `service_worker` | `scripts` |
38+
| Popup Action | `action` | `browser_action` |
39+
| Permissions | Separate `host_permissions` | Combined in `permissions` |
40+
| Web Resources | Object format | Array format |
41+
42+
The JavaScript code is identical - only the manifest configuration differs.
43+
44+
## Browser API Compatibility
45+
46+
All JavaScript files include a compatibility shim at the top:
47+
48+
```javascript
49+
// Browser API compatibility shim for Chrome and Firefox
50+
if (typeof browser === 'undefined') {
51+
var browser = chrome;
52+
}
53+
```
54+
55+
This ensures seamless API compatibility:
56+
- **Firefox**: Natively uses `browser.*` API (returns Promises)
57+
- **Chrome**: Uses `chrome.*` API, polyfill provides `browser.*` wrapper
58+
59+
## Development Workflow
60+
61+
### Manifest Switching
62+
63+
Use the provided script to switch between browser manifests:
64+
65+
```bash
66+
# Switch to Firefox manifest (Manifest V2)
67+
./switch-manifest.sh firefox
68+
69+
# Switch back to Chrome manifest (Manifest V3)
70+
./switch-manifest.sh chrome
71+
```
72+
73+
The script:
74+
- Backs up the current `manifest.json` as `manifest.chrome.json`
75+
- Copies `manifest.firefox.json` to `manifest.json` (or vice versa)
76+
- Ensures you're always using the correct manifest for your target browser
77+
78+
### Testing in Both Browsers
79+
80+
**Chrome:**
81+
```bash
82+
./switch-manifest.sh chrome
83+
# Then reload the extension in chrome://extensions
84+
```
85+
86+
**Firefox:**
87+
```bash
88+
./switch-manifest.sh firefox
89+
# Then remove and re-add the extension in about:debugging
90+
```
91+
92+
### Verifying Active Manifest
93+
94+
Check which manifest is currently active:
95+
96+
```bash
97+
# Check manifest version
98+
grep "manifest_version" extension/manifest.json
99+
100+
# If it shows "2" → Firefox manifest
101+
# If it shows "3" → Chrome manifest
102+
```
103+
104+
## Distribution / Packaging
105+
106+
### Chrome Web Store
107+
108+
1. Create a ZIP file with the `extension/` folder contents
109+
2. **Exclude** `manifest.firefox.json` from the package
110+
3. Include only `manifest.json` (MV3 with service_worker)
111+
112+
```bash
113+
cd extension
114+
zip -r ../crowdassist-chrome.zip . -x "manifest.firefox.json"
115+
```
116+
117+
### Firefox Add-ons (AMO)
118+
119+
1. Create a ZIP file with the `extension/` folder contents
120+
2. **Rename** `manifest.firefox.json` to `manifest.json` before packaging
121+
3. Or use a build script to swap manifests automatically
122+
123+
```bash
124+
cd extension
125+
cp manifest.firefox.json manifest.json
126+
zip -r ../crowdassist-firefox.zip .
127+
git restore manifest.json # restore original
128+
```
129+
130+
## Build Script (Optional)
131+
132+
You can create a simple build script to automate packaging:
133+
134+
```bash
135+
#!/bin/bash
136+
137+
# Build for Chrome
138+
cd extension
139+
zip -r ../dist/crowdassist-chrome.zip . -x "manifest.firefox.json"
140+
141+
# Build for Firefox
142+
cp manifest.firefox.json manifest.json
143+
zip -r ../dist/crowdassist-firefox.zip .
144+
git restore manifest.json
145+
146+
echo "✅ Built packages for both browsers in dist/"
147+
```
148+
149+
## Technical Details
150+
151+
### Service Workers vs Background Scripts
152+
153+
**Chrome MV3** requires service workers:
154+
- Event-driven, non-persistent background script
155+
- More resource efficient
156+
- Required for Chrome Web Store submissions
157+
158+
**Firefox MV2** uses traditional background scripts:
159+
- More stable and mature implementation
160+
- Firefox MV3 service worker support is still experimental
161+
- Fully compatible with all Firefox versions 91+
162+
163+
Both approaches work identically from the extension's perspective thanks to the browser API polyfill.
164+
165+
## Troubleshooting
166+
167+
### Firefox: "service_worker is currently disabled"
168+
169+
This means Firefox tried to use the Chrome manifest. Solution:
170+
- Make sure to select `manifest.firefox.json` when loading
171+
- If you see this error, remove the extension and re-add it
172+
173+
### Chrome: "background.scripts requires manifest version 2 or lower"
174+
175+
This means Chrome tried to use the Firefox manifest. Solution:
176+
- Chrome automatically uses `manifest.json` from the folder
177+
- Make sure `manifest.json` contains `service_worker`, not `scripts`
178+
179+
### Both Browsers: API calls failing
180+
181+
Check that the browser polyfill is present at the top of each JS file:
182+
- `background.js`
183+
- `content.js`
184+
- `popup.js`

README.md

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# CrowdAssist
22

3-
CrowdAssist is a Chrome extension designed specifically for bug bounty researchers and Bug Bounty Platforms. It enhances your research workflow with AI-powered report writing, intelligent automation tools, and productivity features that save time and improve the quality of your vulnerability submissions.
3+
CrowdAssist is a browser extension for **Chrome** and **Firefox** designed specifically for bug bounty researchers and Bug Bounty Platforms. It enhances your research workflow with AI-powered report writing, intelligent automation tools, and productivity features that save time and improve the quality of your vulnerability submissions.
44

55
Whether you're writing reports, managing submissions, or communicating with triager or program teams, CrowdAssist provides the tools you need to work more efficiently and professionally.
66

@@ -85,15 +85,52 @@ Whether you're writing reports, managing submissions, or communicating with tria
8585

8686
## Installation
8787

88-
### Install CrowdAssist
88+
CrowdAssist uses different manifest versions for Chrome and Firefox due to browser-specific requirements. A helper script is provided to easily switch between them.
89+
90+
### Chrome / Chromium / Edge / Brave
91+
92+
1. Download this repository as a ZIP file and unzip it, or clone the repository.
93+
2. **Ensure you're using the Chrome manifest** (default):
94+
```bash
95+
./switch-manifest.sh chrome
96+
```
97+
3. Open your browser and navigate to `chrome://extensions` (or equivalent).
98+
4. Enable "Developer mode" using the toggle in the top-right corner.
99+
5. Click the "Load unpacked" button.
100+
6. Select the `extension` directory.
101+
102+
### Firefox
89103

90104
1. Download this repository as a ZIP file and unzip it, or clone the repository.
91-
2. Open your Chrome browser and navigate to `chrome://extensions`.
92-
3. Enable "Developer mode" using the toggle in the top-right corner.
93-
4. Click the "Load unpacked" button.
94-
5. Select the `CrowdAssist` directory.
105+
2. **Switch to Firefox manifest:**
106+
```bash
107+
./switch-manifest.sh firefox
108+
```
109+
3. Open Firefox and navigate to `about:debugging#/runtime/this-firefox`.
110+
4. Click "Load Temporary Add-on".
111+
5. Navigate to the `extension` directory and select `manifest.json`.
112+
113+
> **Important:** Firefox always reads the file named `manifest.json` from the extension directory. The switch script temporarily replaces it with the Firefox-compatible version.
114+
115+
### Switching Between Browsers
116+
117+
When testing in both browsers during development:
118+
119+
```bash
120+
# Switch to Firefox mode
121+
./switch-manifest.sh firefox
95122

96-
The extension is now installed and will be active on the Bug Bounty Platform pages (Refresh could be needed).
123+
# Switch back to Chrome mode
124+
./switch-manifest.sh chrome
125+
```
126+
127+
The script automatically backs up and restores the correct manifest for each browser.
128+
129+
---
130+
131+
The extension is now installed and will be active on Bug Bounty Platform pages (Refresh could be needed).
132+
133+
> **Technical Note:** Chrome requires Manifest V3 with service workers, while Firefox uses the more stable Manifest V2 with background scripts. The JavaScript code is identical - only the manifest differs. See [BROWSER_COMPATIBILITY.md](BROWSER_COMPATIBILITY.md) for detailed technical information.
97134
98135
### Configure CrowdAssist Settings
99136

@@ -128,6 +165,25 @@ To use CrowdAssist's AI-powered features, you'll need an OpenAI API token:
128165

129166
This is an open-source project. If you have ideas for new features or have found a bug, please feel free to open an issue or submit a pull request.
130167

168+
### Development Workflow
169+
170+
1. **Testing in Both Browsers:**
171+
- Use `./switch-manifest.sh chrome` or `./switch-manifest.sh firefox` to switch between browser manifests
172+
- Test all features in both browsers before submitting PRs
173+
174+
2. **Building Distribution Packages:**
175+
```bash
176+
./build.sh
177+
```
178+
This creates ready-to-distribute ZIP files in the `dist/` directory:
179+
- `crowdassist-chrome.zip` - For Chrome Web Store
180+
- `crowdassist-firefox.zip` - For Firefox Add-ons (AMO)
181+
182+
3. **Code Structure:**
183+
- All JavaScript files include browser API polyfills for cross-browser compatibility
184+
- Manifest files are browser-specific but the codebase is shared
185+
- See [BROWSER_COMPATIBILITY.md](BROWSER_COMPATIBILITY.md) for technical details
186+
131187
## Potential TODOs
132188

133189
- [ ] Implement Hackerone support (Under review)

build.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
# Build script for CrowdAssist - Creates distribution packages for Chrome and Firefox
3+
4+
set -e # Exit on error
5+
6+
echo "🔨 Building CrowdAssist extension packages..."
7+
echo ""
8+
9+
# Create dist directory if it doesn't exist
10+
mkdir -p dist
11+
12+
# Clean previous builds
13+
rm -f dist/crowdassist-chrome.zip
14+
rm -f dist/crowdassist-firefox.zip
15+
16+
# Build for Chrome
17+
echo "📦 Building Chrome package..."
18+
cd extension
19+
zip -r ../dist/crowdassist-chrome.zip . -x "manifest.firefox.json" -x "*.DS_Store"
20+
cd ..
21+
echo "✅ Chrome package: dist/crowdassist-chrome.zip"
22+
echo ""
23+
24+
# Build for Firefox
25+
echo "Building Firefox package..."
26+
cd extension
27+
28+
# Temporarily rename Firefox manifest
29+
cp manifest.json manifest.json.backup
30+
cp manifest.firefox.json manifest.json
31+
32+
zip -r ../dist/crowdassist-firefox.zip . -x "manifest.json.backup" -x "manifest.firefox.json" -x "*.DS_Store"
33+
34+
# Restore original manifest
35+
mv manifest.json.backup manifest.json
36+
37+
cd ..
38+
echo "✅ Firefox package: dist/crowdassist-firefox.zip"
39+
echo ""
40+
41+
# Show file sizes
42+
echo "Package sizes:"
43+
ls -lh dist/*.zip | awk '{print $9 " - " $5}'
44+
echo ""
45+
46+
echo "Build complete! Packages are in the dist/ directory"
47+

0 commit comments

Comments
 (0)