aiohttp
免费Use when building Python async HTTP services or clients with aiohttp - web server routing, middleware, WebSocket, SSE, streaming, client sessions, pytest-aiohttp testing, or troubleshooting SSL and timeout issues
中文简介正在准备中。当前显示原文说明。
Use when developing Firefox WebExtensions - Manifest V2/V3 configuration, WebExtension APIs, content security policy, web-ext CLI, cross-browser support with the polyfill, AMO submission, or debugging extensions
中文简介正在准备中。当前显示原文说明。
查看安装方法安装前可以查看交给 AI 代理的指令内容。
Complete reference for building, testing, and publishing browser extensions for Mozilla Firefox.
Firefox extensions use the WebExtensions API with the browser.* namespace (Promise-based natively). Firefox supports both Manifest V2 and V3, with MV2 NOT deprecated (unlike Chrome).
Key Characteristics:
browser (Promise-based)sidebarAction, userScripts, contextualIdentities, protocol_handlers{
"manifest_version": 3,
"name": "Extension Name",
"version": "1.0.0",
"description": "Brief description",
"browser_specific_settings": {
"gecko": {
"id": "extension@example.com",
"strict_min_version": "109.0"
},
"gecko_android": {
"strict_min_version": "109.0"
}
},
"background": {
"service_worker": "background.js",
"type": "module"
},
"action": {
"default_popup": "popup.html",
"default_icon": {
"16": "icons/icon-16.png",
"48": "icons/icon-48.png",
"96": "icons/icon-96.png"
},
"default_title": "Extension Title"
},
"content_scripts": [
{
"matches": ["https://*/*"],
"js": ["content.js"],
"css": ["styles.css"],
"run_at": "document_idle"
}
],
"permissions": ["storage", "activeTab"],
"host_permissions": ["https://api.example.com/*"],
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self';"
}
}
> See `references/security-crossbrowser.md` for full CSP reference.
### Manifest V2 (Still Supported)
```json
{
"manifest_version": 2,
"name": "Extension Name",
"version": "1.0.0",
"browser_specific_settings": {
"gecko": {
"id": "extension@example.com",
"strict_min_version": "78.0"
}
},
"background": {
"scripts": ["background.js"],
"persistent": false
},
"browser_action": {
"default_popup": "popup.html",
"default_icon": "icons/icon-48.png"
},
"permissions": ["storage", "activeTab", "https://*/*"]
}
| Feature | MV2 | MV3 | Firefox Version Notes |
|---|---|---|---|
| Toolbar button | browser_action | action | action available since Firefox 109+ |
| Background | background.scripts / page | background.service_worker | Service workers since Firefox 109+; MV2 background pages still supported |
| Host permissions | In permissions | Separate host_permissions | MV3 separation enforced from Firefox 109+ |
| Default CSP | script-src 'self'; object-src 'self'; | script-src 'self'; upgrade-insecure-requests; | CSP tightening in MV3 blocks inline scripts |
| Request blocking | webRequest.onBeforeRequest | declarativeNetRequest | MV3: webRequest is non-blocking only; blocking requires declarativeNetRequest (rule limits apply) |
| MV3 availability | N/A | Supported | Firefox 109+ (ESR 115+) — verify against MDN for ESR boundaries |
| MV2 deprecation | Active | N/A | Firefox has NOT deprecated MV2 (unlike Chrome); verify current status on MDN |
MV3 forces these practical changes:
eval(), no dynamic import() from networkbackground.scripts → background.service_worker (event-driven, ephemeral)onclick="...") blocked; move to event listenerswebRequest blocking → declarativeNetRequest (max 30,000 rules, 5,000 dynamic rules)Metadata:
name (required) - Extension nameversion (required) - Version string (e.g., "1.0.0")description - Short descriptionauthor - Author namehomepage_url - Extension homepageicons - Extension icons objectFirefox-Specific:
browser_specific_settings.gecko.id - Required for AMObrowser_specific_settings.gecko.strict_min_version - Minimum Firefox versionbrowser_specific_settings.gecko.strict_max_version - Maximum Firefox versionbrowser_specific_settings.gecko_android - Android-specific settingsBackground & Scripts:
background - Service worker (MV3) or scripts/page (MV2)content_scripts - Scripts injected into pagesuserScripts - User script registration (Firefox-only)declarative_net_request - Rule-based request modificationUI Components:
action (MV3) / browser_action (MV2) - Toolbar buttonpage_action - Address bar buttonsidebar_action - Sidebar panel (Firefox-only)options_ui - Options page configurationdevtools_page - DevTools extension pagePermissions:
permissions - API permissionshost_permissions (MV3) - Host accessoptional_permissions - Optional API permissionsoptional_host_permissions - Optional host accessHigh-risk permissions trigger AMO reviewer scrutiny. Document the narrowest alternative:
| Permission | What it grants | Narrower alternative |
|---|---|---|
<all_urls> | Access to every website | Specific host patterns (https://*.example.com/*) |
webRequest | Inspect/modify all network traffic | declarativeNetRequest for static rules; limit scope with host_permissions |
cookies | Read/write all cookies | host_permissions for specific domains; justify in AMO submission |
debugger | Attach debugger to any tab | Rarely justified; consider devtools API instead |
tabs | Read all tab metadata | activeTab for on-demand access; scripting API for content injection |
bookmarks | Read/modify all bookmarks | None — justify necessity in AMO notes |
history | Read browsing history | None — AMO requires strong justification |
AMO review trigger: Permission justification must appear in the extension listing description or AMO notes. Vague justifications lead to rejection.
Other:
commands - Keyboard shortcutsomnibox - Address bar integrationweb_accessible_resources - Resources accessible from pagesprotocol_handlers - Custom protocol handlerschrome_settings_overrides - Override homepage/searchchrome_url_overrides - Override new tab/bookmarksnpm install -g web-ext
Run extension (development):
web-ext run # Default Firefox
web-ext run --firefox-path /path/to/firefox # Specific Firefox
web-ext run --target firefox-android # Android
web-ext run --profile-create-new # Clean profile
web-ext run --start-url https://example.com # Start URL
web-ext run --verbose # Verbose output
web-ext run --no-reload # Disable auto-reload
Lint extension:
web-ext lint # Validate manifest and code
web-ext lint --warnings-as-errors
web-ext lint --self-hosted # Skip AMO-specific checks
Build extension:
web-ext build # Create .zip in web-ext-artifacts/
web-ext build --source-dir ./src
web-ext build --artifacts-dir ./dist
Sign extension:
web-ext sign --api-key $KEY --api-secret $SECRET
web-ext sign --channel listed # Public on AMO
web-ext sign --channel unlisted # Direct download
Other commands:
web-ext docs # Open documentation
web-ext dump-config # Show configuration
module.exports = {
sourceDir: './src',
artifactsDir: './dist',
run: {
firefox: '/Applications/Firefox.app/Contents/MacOS/firefox',
startUrl: 'https://example.com',
pref: ['extensions.webextensions.debug=true']
},
build: {
overwriteDest: true
},
sign: {
apiKey: process.env.AMO_API_KEY,
apiSecret: process.env.AMO_API_SECRET,
channel: 'listed'
}
};
WEB_EXT_API_KEY=your_key
WEB_EXT_API_SECRET=your_secret
WEB_EXT_SOURCE_DIR=./src
WEB_EXT_ARTIFACTS_DIR=./dist
WEB_EXT_FIREFOX=/path/to/firefox
// Keep service worker alive briefly
let keepAlive;
browser.runtime.onMessage.addListener((msg) => {
clearTimeout(keepAlive);
keepAlive = setTimeout(() => {}, 25000);
return handleMessage(msg);
});
async function safeAsync(fn) {
try {
return await fn();
} catch (error) {
console.error('Error:', error);
return { error: error.message };
}
}
browser.tabs.query() with specific filtersalarms API instead of setInterval in backgroundmy-extension/
├── manifest.json
├── background.js
├── content.js
├── popup.html
├── popup.js
├── options.html
├── options.js
├── browser-polyfill.js
├── styles/
│ ├── popup.css
│ └── content.css
├── icons/
│ ├── icon-16.png
│ ├── icon-32.png
│ ├── icon-48.png
│ └── icon-96.png
├── _locales/
│ ├── en/
│ │ └── messages.json
│ └── it/
│ └── messages.json
├── .web-ext-config.js
├── package.json
└── README.md
Official references:
These issues cause immediate automated or quick human rejection:
| Issue | Fix |
|-------|-----||
| Missing browser_specific_settings.gecko.id | Add unique UUID or email-based ID |
| Data collection disclosure missing | Add data_collection field in manifest or privacy policy URL |
| Homepage/source URL 404s | Verify URLs before submission; use permanent links |
| Icon fails size rules | Provide 48x48 and 96x96 PNGs; no transparency issues |
| Description reads as keyword spam | Write natural description; avoid stuffed keywords |
| Missing permission justification | Document permission usage in AMO notes |
Reviewers manually check for these red flags:
eval(), new Function(), dynamic script loading from network<all_urls> without clear justificationWhen rejected:
If your extension collects/transmits user data, you MUST:
homepage_url or dedicated field)See references/testing-amo.md for the full AMO checklist.
Load these reference files on demand for detailed information:
references/apis.mdreferences/security-crossbrowser.mdreferences/testing-amo.md还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
Use when building Python async HTTP services or clients with aiohttp - web server routing, middleware, WebSocket, SSE, streaming, client sessions, pytest-aiohttp testing, or troubleshooting SSL and timeout issues
中文简介正在准备中。当前显示原文说明。
Use when doing structural code search and rewriting - ast-grep linting, refactoring, multi-language patterns
中文简介正在准备中。当前显示原文说明。
Use when building GBA games with the BPCore Lua engine - entity, sprite and tilemap functions, SRAM save and load, link cable multiplayer protocol, camera and scrolling, or optimization patterns
中文简介正在准备中。当前显示原文说明。
Use when running background tasks with Celery - worker and broker configuration (Redis, RabbitMQ), task routing by name vs queue, chains/groups/chords, retry patterns (autoretry_for, retry_backoff), acks_late semantics, failure detection, and monitoring with Flower
中文简介正在准备中。当前显示原文说明。
Use when building Django applications - security hardening, authentication and permissions, ORM optimization, PostgreSQL features, Django 6.0, migrations, testing, and ecosystem libraries
中文简介正在准备中。当前显示原文说明。
Use when customizing Django Admin - save_formset, get_search_results, formsets, queryset optimization, db_index, custom URLs
中文简介正在准备中。当前显示原文说明。