packwise-skills 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursorrules +23 -23
- package/CLAUDE.md +25 -25
- package/LICENSE +21 -0
- package/README.md +404 -295
- package/audit.md +224 -224
- package/bin/packwise.js +322 -155
- package/install.sh +123 -0
- package/package.json +32 -31
- package/skill.md +944 -719
- package/sub-skills/ai/local-llm.md +183 -183
- package/sub-skills/ai/python-ml.md +164 -164
- package/sub-skills/backend/go-server.md +184 -184
- package/sub-skills/backend/java-spring.md +241 -241
- package/sub-skills/backend/node-server.md +164 -164
- package/sub-skills/backend/php-laravel.md +175 -175
- package/sub-skills/backend/python-server.md +164 -164
- package/sub-skills/backend/rust-backend.md +118 -118
- package/sub-skills/cli/python-cli.md +236 -236
- package/sub-skills/cli/sdk-library.md +497 -497
- package/sub-skills/cloud/ci-cd-pipelines.md +350 -350
- package/sub-skills/cloud/docker.md +191 -191
- package/sub-skills/cloud/kubernetes.md +277 -277
- package/sub-skills/cloud/payment-integration.md +307 -307
- package/sub-skills/cross-platform/multiplatform.md +252 -252
- package/sub-skills/desktop/electron.md +783 -783
- package/sub-skills/desktop/game-dev.md +443 -443
- package/sub-skills/desktop/native-app.md +123 -123
- package/sub-skills/desktop/scenarios.md +443 -443
- package/sub-skills/desktop/smart-platforms.md +324 -324
- package/sub-skills/desktop/tauri.md +428 -428
- package/sub-skills/desktop/vr-ar.md +252 -252
- package/sub-skills/desktop/web-to-desktop.md +153 -153
- package/sub-skills/embedded/car-infotainment.md +129 -129
- package/sub-skills/embedded/esp32.md +184 -184
- package/sub-skills/embedded/ros.md +150 -150
- package/sub-skills/embedded/stm32.md +160 -160
- package/sub-skills/mobile/android.md +322 -322
- package/sub-skills/mobile/capacitor.md +232 -232
- package/sub-skills/mobile/flutter-mobile.md +138 -138
- package/sub-skills/mobile/harmonyos.md +150 -150
- package/sub-skills/mobile/ios.md +245 -245
- package/sub-skills/mobile/react-native.md +443 -443
- package/sub-skills/mobile/wearables.md +230 -230
- package/sub-skills/plugins/browser-extension.md +308 -308
- package/sub-skills/plugins/jetbrains-plugin.md +226 -226
- package/sub-skills/plugins/vscode-extension.md +204 -204
- package/sub-skills/security/security-tools.md +174 -174
- package/sub-skills/web/monorepo.md +274 -274
- package/sub-skills/web/pwa.md +220 -220
- package/sub-skills/web/serverless-edge.md +295 -295
- package/sub-skills/web/spa.md +266 -266
- package/sub-skills/web/ssr.md +228 -228
- package/sub-skills/web/wasm.md +243 -243
|
@@ -1,308 +1,308 @@
|
|
|
1
|
-
# Browser Extension Build Sub-Skill
|
|
2
|
-
|
|
3
|
-
Build and publish browser extensions for Chrome, Edge, Firefox, and Safari.
|
|
4
|
-
|
|
5
|
-
**Current version**: Manifest V3 (MV3) / Chrome 130+ / Firefox 130+ / Safari 18+ (2025-2026)
|
|
6
|
-
|
|
7
|
-
## When to Use
|
|
8
|
-
|
|
9
|
-
- Browser productivity tools (ad blockers, password managers, note-taking)
|
|
10
|
-
- Developer tools (API inspectors, debug panels)
|
|
11
|
-
- Content enhancement (readers, translators, UI overlays)
|
|
12
|
-
- Web scraping / data extraction tools
|
|
13
|
-
- AI-powered browser assistants
|
|
14
|
-
|
|
15
|
-
## Manifest V3 (Required for Chrome/Edge)
|
|
16
|
-
|
|
17
|
-
### Project Structure
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
my-extension/
|
|
21
|
-
├── manifest.json ← Core configuration (MV3)
|
|
22
|
-
├── background.js ← Service Worker (replaces background page)
|
|
23
|
-
├── content.js ← Content script (injected into pages)
|
|
24
|
-
├── popup/
|
|
25
|
-
│ ├── popup.html ← Popup page
|
|
26
|
-
│ └── popup.js
|
|
27
|
-
├── options/
|
|
28
|
-
│ ├── options.html ← Settings page
|
|
29
|
-
│ └── options.js
|
|
30
|
-
├── icons/
|
|
31
|
-
│ ├── icon16.png
|
|
32
|
-
│ ├── icon48.png
|
|
33
|
-
│ └── icon128.png
|
|
34
|
-
└── sidepanel/ ← Chrome Side Panel (optional)
|
|
35
|
-
├── panel.html
|
|
36
|
-
└── panel.js
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### manifest.json Template (MV3)
|
|
40
|
-
|
|
41
|
-
```json
|
|
42
|
-
{
|
|
43
|
-
"manifest_version": 3,
|
|
44
|
-
"name": "My Extension",
|
|
45
|
-
"version": "1.0.0",
|
|
46
|
-
"description": "Extension description",
|
|
47
|
-
"permissions": [
|
|
48
|
-
"activeTab",
|
|
49
|
-
"storage",
|
|
50
|
-
"scripting",
|
|
51
|
-
"sidePanel"
|
|
52
|
-
],
|
|
53
|
-
"host_permissions": ["https://*/*"],
|
|
54
|
-
"background": {
|
|
55
|
-
"service_worker": "background.js"
|
|
56
|
-
},
|
|
57
|
-
"content_scripts": [{
|
|
58
|
-
"matches": ["https://*/*"],
|
|
59
|
-
"js": ["content.js"],
|
|
60
|
-
"css": ["content.css"],
|
|
61
|
-
"run_at": "document_idle"
|
|
62
|
-
}],
|
|
63
|
-
"action": {
|
|
64
|
-
"default_popup": "popup/popup.html",
|
|
65
|
-
"default_icon": {
|
|
66
|
-
"16": "icons/icon16.png",
|
|
67
|
-
"48": "icons/icon48.png",
|
|
68
|
-
"128": "icons/icon128.png"
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
"side_panel": {
|
|
72
|
-
"default_path": "sidepanel/panel.html"
|
|
73
|
-
},
|
|
74
|
-
"icons": {
|
|
75
|
-
"16": "icons/icon16.png",
|
|
76
|
-
"48": "icons/icon48.png",
|
|
77
|
-
"128": "icons/icon128.png"
|
|
78
|
-
},
|
|
79
|
-
"minimum_chrome_version": "116"
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### Background Service Worker (MV3)
|
|
84
|
-
|
|
85
|
-
```javascript
|
|
86
|
-
// background.js — runs as Service Worker (NOT persistent)
|
|
87
|
-
chrome.runtime.onInstalled.addListener(() => {
|
|
88
|
-
console.log('Extension installed');
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
// Listen for messages from content script or popup
|
|
92
|
-
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|
93
|
-
if (message.action === 'getData') {
|
|
94
|
-
chrome.storage.local.get(['data'], (result) => {
|
|
95
|
-
sendResponse(result.data);
|
|
96
|
-
});
|
|
97
|
-
return true; // Keep message channel open for async response
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
// Side Panel API
|
|
102
|
-
chrome.sidePanel.setOptions({ path: 'sidepanel/panel.html', enabled: true });
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### Content Script
|
|
106
|
-
|
|
107
|
-
```javascript
|
|
108
|
-
// content.js — runs in the context of web pages
|
|
109
|
-
// Can access DOM but NOT Chrome APIs directly
|
|
110
|
-
// Communicate with background via chrome.runtime.sendMessage
|
|
111
|
-
|
|
112
|
-
const data = document.title;
|
|
113
|
-
chrome.runtime.sendMessage({ action: 'pageTitle', data });
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
### Build Tools (Bundling with Vite/Webpack)
|
|
117
|
-
|
|
118
|
-
```bash
|
|
119
|
-
npm install -D @crxjs/vite-plugin # For Vite projects
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
```javascript
|
|
123
|
-
// vite.config.js
|
|
124
|
-
import { crx } from '@crxjs/vite-plugin';
|
|
125
|
-
import manifest from './manifest.json';
|
|
126
|
-
|
|
127
|
-
export default {
|
|
128
|
-
plugins: [crx({ manifest })],
|
|
129
|
-
build: {
|
|
130
|
-
rollupOptions: {
|
|
131
|
-
input: { background: 'background.js' },
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
};
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
---
|
|
138
|
-
|
|
139
|
-
## Firefox Extension (Manifest V3 Support)
|
|
140
|
-
|
|
141
|
-
Firefox now supports MV3. Add `browser_specific_settings` to manifest.json:
|
|
142
|
-
|
|
143
|
-
```json
|
|
144
|
-
{
|
|
145
|
-
"manifest_version": 3,
|
|
146
|
-
"browser_specific_settings": {
|
|
147
|
-
"gecko": {
|
|
148
|
-
"id": "my-extension@example.com",
|
|
149
|
-
"strict_min_version": "109.0"
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
### Firefox-Specific Differences
|
|
156
|
-
|
|
157
|
-
| Feature | Chrome MV3 | Firefox MV3 |
|
|
158
|
-
|---------|-----------|-------------|
|
|
159
|
-
| Background | Service Worker (ephemeral) | Event pages (can be persistent) |
|
|
160
|
-
| `browser` API | `chrome.*` | `browser.*` (promise-based) + `chrome.*` (compat) |
|
|
161
|
-
| Storage | `chrome.storage` | `browser.storage` |
|
|
162
|
-
| Side Panel | Supported | Not supported |
|
|
163
|
-
| `webRequest` blocking | Removed (use `declarativeNetRequest`) | Still supported |
|
|
164
|
-
|
|
165
|
-
### Cross-Browser Build (WXT Framework)
|
|
166
|
-
|
|
167
|
-
```bash
|
|
168
|
-
npm install -D wxt
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
```bash
|
|
172
|
-
# Development
|
|
173
|
-
npx wxt dev
|
|
174
|
-
|
|
175
|
-
# Build for Chrome
|
|
176
|
-
npx wxt build --browser chrome
|
|
177
|
-
# Output: .output/chrome-mv3/
|
|
178
|
-
|
|
179
|
-
# Build for Firefox
|
|
180
|
-
npx wxt build --browser firefox
|
|
181
|
-
# Output: .output/firefox-mv2/
|
|
182
|
-
|
|
183
|
-
# Build for all browsers
|
|
184
|
-
npx wxt zip # Creates .zip for store upload
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
---
|
|
188
|
-
|
|
189
|
-
## Safari Extension
|
|
190
|
-
|
|
191
|
-
### Option 1: Web Extension (Recommended — share code with Chrome/Firefox)
|
|
192
|
-
|
|
193
|
-
```bash
|
|
194
|
-
# In Xcode:
|
|
195
|
-
# File → New → Target → Safari Web Extension
|
|
196
|
-
# Import your Chrome MV3 extension
|
|
197
|
-
# Xcode converts it to Safari format
|
|
198
|
-
|
|
199
|
-
# Build
|
|
200
|
-
xcodebuild -scheme MyApp-Extension -configuration Release archive
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
### Option 2: Safari App Extension (Native Swift)
|
|
204
|
-
|
|
205
|
-
```swift
|
|
206
|
-
import SafariServices
|
|
207
|
-
|
|
208
|
-
class SafariExtensionHandler: SFSafariExtensionHandler {
|
|
209
|
-
override func messageReceived(withName messageName: String, from page: SFSafariPage, userInfo: [String: Any]?) {
|
|
210
|
-
page.dispatchMessageToScript(withName: "response", userInfo: ["data": "Hello from native!"])
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### Safari-Specific Notes
|
|
216
|
-
|
|
217
|
-
- Safari uses Web Extension format (similar to MV3 but with limitations)
|
|
218
|
-
- Requires macOS + Xcode
|
|
219
|
-
- Distributed via App Store ($99/year developer account)
|
|
220
|
-
- Some Chrome APIs not available in Safari
|
|
221
|
-
|
|
222
|
-
---
|
|
223
|
-
|
|
224
|
-
## Packaging & Publishing
|
|
225
|
-
|
|
226
|
-
### Chrome Web Store
|
|
227
|
-
|
|
228
|
-
```bash
|
|
229
|
-
# 1. Build production version
|
|
230
|
-
npm run build
|
|
231
|
-
|
|
232
|
-
# 2. Zip the extension
|
|
233
|
-
zip -r my-extension.zip manifest.json *.js *.css popup/ options/ icons/
|
|
234
|
-
|
|
235
|
-
# 3. Upload to Chrome Web Store
|
|
236
|
-
# chrome.google.com/webstore/devconsole
|
|
237
|
-
# - Pay $5 one-time registration fee
|
|
238
|
-
# - Upload .zip
|
|
239
|
-
# - Fill: description, screenshots (1280x800), privacy policy URL
|
|
240
|
-
# - Submit for review (1–7 days)
|
|
241
|
-
|
|
242
|
-
# Or: automated with GitHub Action
|
|
243
|
-
# wxtjs/wxt-builder-action
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
### Edge Add-ons
|
|
247
|
-
|
|
248
|
-
```bash
|
|
249
|
-
# Same .zip works for Edge
|
|
250
|
-
# partner.microsoft.com/dashboard
|
|
251
|
-
# Upload .zip → Submit for review (1–3 days)
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
### Firefox Add-ons
|
|
255
|
-
|
|
256
|
-
```bash
|
|
257
|
-
# addons.mozilla.org/developers/
|
|
258
|
-
# Upload .zip → Submit for review (1–7 days, sometimes longer)
|
|
259
|
-
# No registration fee
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
### Safari Extensions
|
|
263
|
-
|
|
264
|
-
```bash
|
|
265
|
-
# App Store Connect → New App → macOS
|
|
266
|
-
# Upload .xcarchive via Xcode
|
|
267
|
-
# Requires Apple Developer account ($99/year)
|
|
268
|
-
# Review: 1–3 days
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
---
|
|
272
|
-
|
|
273
|
-
## Store Comparison
|
|
274
|
-
|
|
275
|
-
| Store | Fee | Review Time | User Base | Auto-Update |
|
|
276
|
-
|-------|-----|-------------|-----------|-------------|
|
|
277
|
-
| Chrome Web Store | $5 one-time | 1–7 days | 3B+ users | Yes |
|
|
278
|
-
| Edge Add-ons | Free | 1–3 days | 300M+ users | Yes |
|
|
279
|
-
| Firefox Add-ons | Free | 1–7 days | 200M+ users | Yes |
|
|
280
|
-
| Safari Extensions | $99/year | 1–3 days | 1B+ devices | Yes (via App Store) |
|
|
281
|
-
|
|
282
|
-
---
|
|
283
|
-
|
|
284
|
-
## MV3 Migration Checklist (from MV2)
|
|
285
|
-
|
|
286
|
-
| MV2 Feature | MV3 Replacement |
|
|
287
|
-
|-------------|----------------|
|
|
288
|
-
| Background page | Service Worker |
|
|
289
|
-
| `chrome.browserAction` | `chrome.action` |
|
|
290
|
-
| `webRequest` blocking | `declarativeNetRequest` |
|
|
291
|
-
| Remote code execution | Bundled code only |
|
|
292
|
-
| `eval()` | Not allowed |
|
|
293
|
-
| Persistent background | Event-driven (non-persistent) |
|
|
294
|
-
| `chrome.extension.getURL` | `chrome.runtime.getURL` |
|
|
295
|
-
|
|
296
|
-
## Common Pitfalls
|
|
297
|
-
|
|
298
|
-
| Issue | Fix |
|
|
299
|
-
|-------|-----|
|
|
300
|
-
| V2 deprecated | Migrate to V3 (Service Worker replaces Background Page) |
|
|
301
|
-
| CSP restriction in MV3 | No remote code; bundle all dependencies |
|
|
302
|
-
| Too many permissions rejected | Minimize permissions; use `activeTab` instead of `<all_urls>` |
|
|
303
|
-
| Review rejected | Ensure privacy policy URL is valid; minimize data collection |
|
|
304
|
-
| Service Worker dies | MV3 Service Workers are ephemeral; use `chrome.alarms` for periodic tasks |
|
|
305
|
-
| Content script not injecting | Check `matches` pattern; verify `run_at` setting |
|
|
306
|
-
| `chrome.storage` not persisting | Use `chrome.storage.sync` for cross-device; `local` for device-only |
|
|
307
|
-
| Cross-browser compatibility | Use WXT or webextension-polyfill for unified API |
|
|
308
|
-
| Popup not showing | Check popup.html exists; verify `default_popup` in manifest |
|
|
1
|
+
# Browser Extension Build Sub-Skill
|
|
2
|
+
|
|
3
|
+
Build and publish browser extensions for Chrome, Edge, Firefox, and Safari.
|
|
4
|
+
|
|
5
|
+
**Current version**: Manifest V3 (MV3) / Chrome 130+ / Firefox 130+ / Safari 18+ (2025-2026)
|
|
6
|
+
|
|
7
|
+
## When to Use
|
|
8
|
+
|
|
9
|
+
- Browser productivity tools (ad blockers, password managers, note-taking)
|
|
10
|
+
- Developer tools (API inspectors, debug panels)
|
|
11
|
+
- Content enhancement (readers, translators, UI overlays)
|
|
12
|
+
- Web scraping / data extraction tools
|
|
13
|
+
- AI-powered browser assistants
|
|
14
|
+
|
|
15
|
+
## Manifest V3 (Required for Chrome/Edge)
|
|
16
|
+
|
|
17
|
+
### Project Structure
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
my-extension/
|
|
21
|
+
├── manifest.json ← Core configuration (MV3)
|
|
22
|
+
├── background.js ← Service Worker (replaces background page)
|
|
23
|
+
├── content.js ← Content script (injected into pages)
|
|
24
|
+
├── popup/
|
|
25
|
+
│ ├── popup.html ← Popup page
|
|
26
|
+
│ └── popup.js
|
|
27
|
+
├── options/
|
|
28
|
+
│ ├── options.html ← Settings page
|
|
29
|
+
│ └── options.js
|
|
30
|
+
├── icons/
|
|
31
|
+
│ ├── icon16.png
|
|
32
|
+
│ ├── icon48.png
|
|
33
|
+
│ └── icon128.png
|
|
34
|
+
└── sidepanel/ ← Chrome Side Panel (optional)
|
|
35
|
+
├── panel.html
|
|
36
|
+
└── panel.js
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### manifest.json Template (MV3)
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"manifest_version": 3,
|
|
44
|
+
"name": "My Extension",
|
|
45
|
+
"version": "1.0.0",
|
|
46
|
+
"description": "Extension description",
|
|
47
|
+
"permissions": [
|
|
48
|
+
"activeTab",
|
|
49
|
+
"storage",
|
|
50
|
+
"scripting",
|
|
51
|
+
"sidePanel"
|
|
52
|
+
],
|
|
53
|
+
"host_permissions": ["https://*/*"],
|
|
54
|
+
"background": {
|
|
55
|
+
"service_worker": "background.js"
|
|
56
|
+
},
|
|
57
|
+
"content_scripts": [{
|
|
58
|
+
"matches": ["https://*/*"],
|
|
59
|
+
"js": ["content.js"],
|
|
60
|
+
"css": ["content.css"],
|
|
61
|
+
"run_at": "document_idle"
|
|
62
|
+
}],
|
|
63
|
+
"action": {
|
|
64
|
+
"default_popup": "popup/popup.html",
|
|
65
|
+
"default_icon": {
|
|
66
|
+
"16": "icons/icon16.png",
|
|
67
|
+
"48": "icons/icon48.png",
|
|
68
|
+
"128": "icons/icon128.png"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"side_panel": {
|
|
72
|
+
"default_path": "sidepanel/panel.html"
|
|
73
|
+
},
|
|
74
|
+
"icons": {
|
|
75
|
+
"16": "icons/icon16.png",
|
|
76
|
+
"48": "icons/icon48.png",
|
|
77
|
+
"128": "icons/icon128.png"
|
|
78
|
+
},
|
|
79
|
+
"minimum_chrome_version": "116"
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Background Service Worker (MV3)
|
|
84
|
+
|
|
85
|
+
```javascript
|
|
86
|
+
// background.js — runs as Service Worker (NOT persistent)
|
|
87
|
+
chrome.runtime.onInstalled.addListener(() => {
|
|
88
|
+
console.log('Extension installed');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// Listen for messages from content script or popup
|
|
92
|
+
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|
93
|
+
if (message.action === 'getData') {
|
|
94
|
+
chrome.storage.local.get(['data'], (result) => {
|
|
95
|
+
sendResponse(result.data);
|
|
96
|
+
});
|
|
97
|
+
return true; // Keep message channel open for async response
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Side Panel API
|
|
102
|
+
chrome.sidePanel.setOptions({ path: 'sidepanel/panel.html', enabled: true });
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Content Script
|
|
106
|
+
|
|
107
|
+
```javascript
|
|
108
|
+
// content.js — runs in the context of web pages
|
|
109
|
+
// Can access DOM but NOT Chrome APIs directly
|
|
110
|
+
// Communicate with background via chrome.runtime.sendMessage
|
|
111
|
+
|
|
112
|
+
const data = document.title;
|
|
113
|
+
chrome.runtime.sendMessage({ action: 'pageTitle', data });
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Build Tools (Bundling with Vite/Webpack)
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
npm install -D @crxjs/vite-plugin # For Vite projects
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
```javascript
|
|
123
|
+
// vite.config.js
|
|
124
|
+
import { crx } from '@crxjs/vite-plugin';
|
|
125
|
+
import manifest from './manifest.json';
|
|
126
|
+
|
|
127
|
+
export default {
|
|
128
|
+
plugins: [crx({ manifest })],
|
|
129
|
+
build: {
|
|
130
|
+
rollupOptions: {
|
|
131
|
+
input: { background: 'background.js' },
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Firefox Extension (Manifest V3 Support)
|
|
140
|
+
|
|
141
|
+
Firefox now supports MV3. Add `browser_specific_settings` to manifest.json:
|
|
142
|
+
|
|
143
|
+
```json
|
|
144
|
+
{
|
|
145
|
+
"manifest_version": 3,
|
|
146
|
+
"browser_specific_settings": {
|
|
147
|
+
"gecko": {
|
|
148
|
+
"id": "my-extension@example.com",
|
|
149
|
+
"strict_min_version": "109.0"
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Firefox-Specific Differences
|
|
156
|
+
|
|
157
|
+
| Feature | Chrome MV3 | Firefox MV3 |
|
|
158
|
+
|---------|-----------|-------------|
|
|
159
|
+
| Background | Service Worker (ephemeral) | Event pages (can be persistent) |
|
|
160
|
+
| `browser` API | `chrome.*` | `browser.*` (promise-based) + `chrome.*` (compat) |
|
|
161
|
+
| Storage | `chrome.storage` | `browser.storage` |
|
|
162
|
+
| Side Panel | Supported | Not supported |
|
|
163
|
+
| `webRequest` blocking | Removed (use `declarativeNetRequest`) | Still supported |
|
|
164
|
+
|
|
165
|
+
### Cross-Browser Build (WXT Framework)
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
npm install -D wxt
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
# Development
|
|
173
|
+
npx wxt dev
|
|
174
|
+
|
|
175
|
+
# Build for Chrome
|
|
176
|
+
npx wxt build --browser chrome
|
|
177
|
+
# Output: .output/chrome-mv3/
|
|
178
|
+
|
|
179
|
+
# Build for Firefox
|
|
180
|
+
npx wxt build --browser firefox
|
|
181
|
+
# Output: .output/firefox-mv2/
|
|
182
|
+
|
|
183
|
+
# Build for all browsers
|
|
184
|
+
npx wxt zip # Creates .zip for store upload
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Safari Extension
|
|
190
|
+
|
|
191
|
+
### Option 1: Web Extension (Recommended — share code with Chrome/Firefox)
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
# In Xcode:
|
|
195
|
+
# File → New → Target → Safari Web Extension
|
|
196
|
+
# Import your Chrome MV3 extension
|
|
197
|
+
# Xcode converts it to Safari format
|
|
198
|
+
|
|
199
|
+
# Build
|
|
200
|
+
xcodebuild -scheme MyApp-Extension -configuration Release archive
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Option 2: Safari App Extension (Native Swift)
|
|
204
|
+
|
|
205
|
+
```swift
|
|
206
|
+
import SafariServices
|
|
207
|
+
|
|
208
|
+
class SafariExtensionHandler: SFSafariExtensionHandler {
|
|
209
|
+
override func messageReceived(withName messageName: String, from page: SFSafariPage, userInfo: [String: Any]?) {
|
|
210
|
+
page.dispatchMessageToScript(withName: "response", userInfo: ["data": "Hello from native!"])
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Safari-Specific Notes
|
|
216
|
+
|
|
217
|
+
- Safari uses Web Extension format (similar to MV3 but with limitations)
|
|
218
|
+
- Requires macOS + Xcode
|
|
219
|
+
- Distributed via App Store ($99/year developer account)
|
|
220
|
+
- Some Chrome APIs not available in Safari
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## Packaging & Publishing
|
|
225
|
+
|
|
226
|
+
### Chrome Web Store
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
# 1. Build production version
|
|
230
|
+
npm run build
|
|
231
|
+
|
|
232
|
+
# 2. Zip the extension
|
|
233
|
+
zip -r my-extension.zip manifest.json *.js *.css popup/ options/ icons/
|
|
234
|
+
|
|
235
|
+
# 3. Upload to Chrome Web Store
|
|
236
|
+
# chrome.google.com/webstore/devconsole
|
|
237
|
+
# - Pay $5 one-time registration fee
|
|
238
|
+
# - Upload .zip
|
|
239
|
+
# - Fill: description, screenshots (1280x800), privacy policy URL
|
|
240
|
+
# - Submit for review (1–7 days)
|
|
241
|
+
|
|
242
|
+
# Or: automated with GitHub Action
|
|
243
|
+
# wxtjs/wxt-builder-action
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Edge Add-ons
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
# Same .zip works for Edge
|
|
250
|
+
# partner.microsoft.com/dashboard
|
|
251
|
+
# Upload .zip → Submit for review (1–3 days)
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Firefox Add-ons
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
# addons.mozilla.org/developers/
|
|
258
|
+
# Upload .zip → Submit for review (1–7 days, sometimes longer)
|
|
259
|
+
# No registration fee
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Safari Extensions
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
# App Store Connect → New App → macOS
|
|
266
|
+
# Upload .xcarchive via Xcode
|
|
267
|
+
# Requires Apple Developer account ($99/year)
|
|
268
|
+
# Review: 1–3 days
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## Store Comparison
|
|
274
|
+
|
|
275
|
+
| Store | Fee | Review Time | User Base | Auto-Update |
|
|
276
|
+
|-------|-----|-------------|-----------|-------------|
|
|
277
|
+
| Chrome Web Store | $5 one-time | 1–7 days | 3B+ users | Yes |
|
|
278
|
+
| Edge Add-ons | Free | 1–3 days | 300M+ users | Yes |
|
|
279
|
+
| Firefox Add-ons | Free | 1–7 days | 200M+ users | Yes |
|
|
280
|
+
| Safari Extensions | $99/year | 1–3 days | 1B+ devices | Yes (via App Store) |
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## MV3 Migration Checklist (from MV2)
|
|
285
|
+
|
|
286
|
+
| MV2 Feature | MV3 Replacement |
|
|
287
|
+
|-------------|----------------|
|
|
288
|
+
| Background page | Service Worker |
|
|
289
|
+
| `chrome.browserAction` | `chrome.action` |
|
|
290
|
+
| `webRequest` blocking | `declarativeNetRequest` |
|
|
291
|
+
| Remote code execution | Bundled code only |
|
|
292
|
+
| `eval()` | Not allowed |
|
|
293
|
+
| Persistent background | Event-driven (non-persistent) |
|
|
294
|
+
| `chrome.extension.getURL` | `chrome.runtime.getURL` |
|
|
295
|
+
|
|
296
|
+
## Common Pitfalls
|
|
297
|
+
|
|
298
|
+
| Issue | Fix |
|
|
299
|
+
|-------|-----|
|
|
300
|
+
| V2 deprecated | Migrate to V3 (Service Worker replaces Background Page) |
|
|
301
|
+
| CSP restriction in MV3 | No remote code; bundle all dependencies |
|
|
302
|
+
| Too many permissions rejected | Minimize permissions; use `activeTab` instead of `<all_urls>` |
|
|
303
|
+
| Review rejected | Ensure privacy policy URL is valid; minimize data collection |
|
|
304
|
+
| Service Worker dies | MV3 Service Workers are ephemeral; use `chrome.alarms` for periodic tasks |
|
|
305
|
+
| Content script not injecting | Check `matches` pattern; verify `run_at` setting |
|
|
306
|
+
| `chrome.storage` not persisting | Use `chrome.storage.sync` for cross-device; `local` for device-only |
|
|
307
|
+
| Cross-browser compatibility | Use WXT or webextension-polyfill for unified API |
|
|
308
|
+
| Popup not showing | Check popup.html exists; verify `default_popup` in manifest |
|