@musashishao/agent-kit 1.8.2 → 1.9.1
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/.agent/agents/ai-architect.md +39 -0
- package/.agent/agents/ai-asset-factory.md +700 -0
- package/.agent/agents/ai-audio-factory.md +503 -0
- package/.agent/agents/cloud-engineer.md +39 -0
- package/.agent/agents/game-developer.md +190 -89
- package/.agent/agents/marketing-specialist.md +41 -0
- package/.agent/agents/orchestrator.md +113 -3
- package/.agent/agents/penetration-tester.md +15 -1
- package/.agent/agents/project-planner.md +67 -0
- package/.agent/agents/unity-mobile-master.md +949 -0
- package/.agent/mcp/config/registry.json +65 -51
- package/.agent/mcp/servers/notebooklm/README.md +114 -0
- package/.agent/mcp/servers/notebooklm/package.json +35 -0
- package/.agent/mcp/servers/notebooklm/src/auth/chrome.ts +225 -0
- package/.agent/mcp/servers/notebooklm/src/auth/index.ts +1 -0
- package/.agent/mcp/servers/notebooklm/src/index.ts +516 -0
- package/.agent/mcp/servers/notebooklm/src/services/index.ts +3 -0
- package/.agent/mcp/servers/notebooklm/src/services/library.ts +217 -0
- package/.agent/mcp/servers/notebooklm/src/services/notebooklm.ts +380 -0
- package/.agent/mcp/servers/notebooklm/tsconfig.json +15 -0
- package/.agent/mcp-gateway/README.md +169 -20
- package/.agent/mcp-gateway/package.json +22 -7
- package/.agent/mcp-gateway/src/auth/index.ts +55 -0
- package/.agent/mcp-gateway/src/auth/middleware.ts +242 -0
- package/.agent/mcp-gateway/src/auth/oauth.ts +462 -0
- package/.agent/mcp-gateway/src/auth/scopes.ts +227 -0
- package/.agent/mcp-gateway/src/index.ts +252 -105
- package/.agent/mcp-gateway/src/observability/index.ts +5 -0
- package/.agent/mcp-gateway/src/observability/otel.ts +405 -0
- package/.agent/mcp-gateway/src/transports/index.ts +5 -0
- package/.agent/mcp-gateway/src/transports/streamableHttp.ts +235 -0
- package/.agent/rules/CODEX.md +115 -2
- package/.agent/rules/CODE_RULES.md +73 -0
- package/.agent/rules/GEMINI.md +26 -1
- package/.agent/rules/MEMORY_STATE.md +110 -0
- package/.agent/rules/REFERENCE.md +40 -58
- package/.agent/rules/REF_SKILLS.md +116 -0
- package/.agent/rules/REF_WORKFLOWS.md +81 -0
- package/.agent/scripts/ak_cli.py +106 -5
- package/.agent/scripts/memory_manager.py +48 -9
- package/.agent/skills/3d-web-experience/SKILL.md +386 -0
- package/.agent/skills/DEPENDENCIES.md +54 -0
- package/.agent/skills/ab-test-setup/SKILL.md +77 -0
- package/.agent/skills/active-directory-attacks/SKILL.md +59 -0
- package/.agent/skills/agent-evaluation/SKILL.md +430 -0
- package/.agent/skills/agent-memory-systems/SKILL.md +426 -0
- package/.agent/skills/agent-tool-builder/SKILL.md +139 -0
- package/.agent/skills/ai-agents-architect/SKILL.md +115 -0
- package/.agent/skills/ai-product/SKILL.md +86 -0
- package/.agent/skills/ai-wrapper-product/SKILL.md +90 -0
- package/.agent/skills/analytics-tracking/SKILL.md +88 -0
- package/.agent/skills/anti-hallucination/SKILL.md +295 -0
- package/.agent/skills/anti-hallucination/scripts/check_hallucination.py +299 -0
- package/.agent/skills/api-fuzzing-bug-bounty/SKILL.md +66 -0
- package/.agent/skills/app-store-optimization/SKILL.md +66 -0
- package/.agent/skills/autonomous-agent-patterns/SKILL.md +414 -0
- package/.agent/skills/aws-penetration-testing/SKILL.md +50 -0
- package/.agent/skills/aws-serverless/SKILL.md +327 -0
- package/.agent/skills/azure-functions/SKILL.md +340 -0
- package/.agent/skills/bifurcation-analysis/SKILL.md +56 -0
- package/.agent/skills/brainstorming/SKILL.md +80 -6
- package/.agent/skills/broken-authentication/SKILL.md +53 -0
- package/.agent/skills/browser-automation/SKILL.md +408 -0
- package/.agent/skills/browser-extension-builder/SKILL.md +422 -0
- package/.agent/skills/bullmq-specialist/SKILL.md +424 -0
- package/.agent/skills/bun-development/SKILL.md +386 -0
- package/.agent/skills/burp-suite-testing/SKILL.md +60 -0
- package/.agent/skills/clerk-auth/SKILL.md +432 -0
- package/.agent/skills/cloud-penetration-testing/SKILL.md +51 -0
- package/.agent/skills/copywriting/SKILL.md +66 -0
- package/.agent/skills/crewai/SKILL.md +470 -0
- package/.agent/skills/decision-memory/SKILL.md +317 -0
- package/.agent/skills/discord-bot-architect/SKILL.md +447 -0
- package/.agent/skills/email-sequence/SKILL.md +73 -0
- package/.agent/skills/emergence-detector/SKILL.md +230 -0
- package/.agent/skills/emergence-detector/scripts/check_emergence.py +265 -0
- package/.agent/skills/ethical-hacking-methodology/SKILL.md +67 -0
- package/.agent/skills/explained-qa/SKILL.md +142 -0
- package/.agent/skills/explained-qa/game-terminology.md +214 -0
- package/.agent/skills/firebase/SKILL.md +377 -0
- package/.agent/skills/game-development/ai-dialogue-engine/SKILL.md +442 -0
- package/.agent/skills/game-development/ai-graphics-generator/SKILL.md +463 -0
- package/.agent/skills/game-development/ai-playtest-framework/SKILL.md +570 -0
- package/.agent/skills/game-development/camera-systems/SKILL.md +607 -0
- package/.agent/skills/game-development/card-battle-engine/SKILL.md +618 -0
- package/.agent/skills/game-development/character-controller-3d/SKILL.md +908 -0
- package/.agent/skills/game-development/cloud-save-sync/SKILL.md +527 -0
- package/.agent/skills/game-development/combat-system/SKILL.md +748 -0
- package/.agent/skills/game-development/compliance-rating/SKILL.md +277 -0
- package/.agent/skills/game-development/crossplatform-build/SKILL.md +386 -0
- package/.agent/skills/game-development/cultivation-progression/SKILL.md +520 -0
- package/.agent/skills/game-development/data-driven-balance/SKILL.md +535 -0
- package/.agent/skills/game-development/game-analytics-integrator/SKILL.md +410 -0
- package/.agent/skills/game-development/game-audio-advanced/SKILL.md +646 -0
- package/.agent/skills/game-development/game-economy-designer/SKILL.md +375 -0
- package/.agent/skills/game-development/game-marketing/SKILL.md +85 -0
- package/.agent/skills/game-development/game-state-manager/SKILL.md +883 -0
- package/.agent/skills/game-development/godot-expert/SKILL.md +462 -0
- package/.agent/skills/game-development/hybrid-game-spec/SKILL.md +220 -0
- package/.agent/skills/game-development/inventory-quest/SKILL.md +747 -0
- package/.agent/skills/game-development/liveops/SKILL.md +308 -0
- package/.agent/skills/game-development/localization/SKILL.md +286 -0
- package/.agent/skills/game-development/mobile-input-patterns/SKILL.md +343 -0
- package/.agent/skills/game-development/monetization-strategy/SKILL.md +94 -0
- package/.agent/skills/game-development/multiplayer-master/SKILL.md +727 -0
- package/.agent/skills/game-development/narrative-branching/SKILL.md +593 -0
- package/.agent/skills/game-development/npc-ai-integration/SKILL.md +110 -0
- package/.agent/skills/game-development/procedural-generation/SKILL.md +168 -0
- package/.agent/skills/game-development/procedural-level-ai/SKILL.md +367 -0
- package/.agent/skills/game-development/prototyping-rapid/SKILL.md +205 -0
- package/.agent/skills/game-development/spec-ecosystem/SKILL.md +155 -0
- package/.agent/skills/game-development/spec-ecosystem/decision-log-format.md +129 -0
- package/.agent/skills/game-development/spec-ecosystem/templates/PLAN-template.md +178 -0
- package/.agent/skills/game-development/spec-ecosystem/templates/SPEC-template.md +110 -0
- package/.agent/skills/game-development/spec-ecosystem/templates/TASKS-template.md +156 -0
- package/.agent/skills/game-development/survival-systems/SKILL.md +493 -0
- package/.agent/skills/game-development/testing-qa/SKILL.md +270 -0
- package/.agent/skills/game-development/unity-integration/SKILL.md +358 -0
- package/.agent/skills/game-development/unity-mobile-optimization/SKILL.md +271 -0
- package/.agent/skills/game-development/webgpu-shading/SKILL.md +209 -0
- package/.agent/skills/gcp-cloud-run/SKILL.md +358 -0
- package/.agent/skills/graphql/SKILL.md +492 -0
- package/.agent/skills/idor-testing/SKILL.md +64 -0
- package/.agent/skills/inngest/SKILL.md +128 -0
- package/.agent/skills/intent-capture/SKILL.md +65 -0
- package/.agent/skills/langfuse/SKILL.md +415 -0
- package/.agent/skills/langgraph/SKILL.md +360 -0
- package/.agent/skills/launch-strategy/SKILL.md +68 -0
- package/.agent/skills/linux-privilege-escalation/SKILL.md +62 -0
- package/.agent/skills/llm-app-patterns/SKILL.md +367 -0
- package/.agent/skills/marketing-ideas/SKILL.md +66 -0
- package/.agent/skills/mcp-composition/SKILL.md +362 -0
- package/.agent/skills/mcp-observability/SKILL.md +323 -0
- package/.agent/skills/mcp-security/SKILL.md +314 -0
- package/.agent/skills/metasploit-framework/SKILL.md +60 -0
- package/.agent/skills/micro-saas-launcher/SKILL.md +93 -0
- package/.agent/skills/neon-postgres/SKILL.md +339 -0
- package/.agent/skills/paid-ads/SKILL.md +64 -0
- package/.agent/skills/supabase-integration/SKILL.md +411 -0
- package/.agent/skills/trust-spectrum/SKILL.md +291 -0
- package/.agent/skills/vibe-coding-guard/SKILL.md +328 -0
- package/.agent/templates/AGENTS.game.md +63 -0
- package/.agent/templates/docs/WORKFLOW_GUIDE.en.md +100 -0
- package/.agent/templates/docs/WORKFLOW_GUIDE.vi.md +100 -0
- package/.agent/workflows/ai-agent.md +38 -0
- package/.agent/workflows/autofix.md +1 -0
- package/.agent/workflows/brainstorm.md +1 -0
- package/.agent/workflows/context.md +1 -0
- package/.agent/workflows/create.md +39 -8
- package/.agent/workflows/dashboard.md +1 -0
- package/.agent/workflows/debug.md +14 -0
- package/.agent/workflows/deploy.md +14 -0
- package/.agent/workflows/enhance.md +44 -0
- package/.agent/workflows/gamekit-init.md +177 -0
- package/.agent/workflows/gamekit-launch.md +338 -0
- package/.agent/workflows/gamekit-plan.md +204 -0
- package/.agent/workflows/gamekit-qa.md +153 -0
- package/.agent/workflows/gamekit-spec.md +243 -0
- package/.agent/workflows/gamekit-tasks.md +208 -0
- package/.agent/workflows/marketing.md +39 -0
- package/.agent/workflows/next.md +1 -0
- package/.agent/workflows/orchestrate.md +12 -0
- package/.agent/workflows/pentest.md +39 -0
- package/.agent/workflows/plan.md +42 -0
- package/.agent/workflows/preview.md +1 -0
- package/.agent/workflows/quality.md +1 -0
- package/.agent/workflows/saas.md +38 -0
- package/.agent/workflows/spec.md +42 -0
- package/.agent/workflows/status.md +1 -0
- package/.agent/workflows/test.md +14 -0
- package/.agent/workflows/ui-ux-pro-max.md +1 -0
- package/README.md +4 -4
- package/bin/cli.js +411 -111
- package/package.json +1 -2
- package/docs/AI_DATA_INFRASTRUCTURE.md +0 -288
- package/docs/CHANGELOG_AI_INFRA.md +0 -111
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: browser-extension-builder
|
|
3
|
+
description: "Build browser extensions for Chrome, Firefox, and Edge. Covers manifest v3, content scripts, background workers, and popup UIs."
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 🧩 Browser Extension Builder
|
|
8
|
+
|
|
9
|
+
You are a browser extension developer who builds extensions that enhance web experiences. You understand Manifest V3, the Chrome Extensions API, cross-browser compatibility, and extension store requirements.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## When to Use This Skill
|
|
14
|
+
|
|
15
|
+
- Building productivity extensions
|
|
16
|
+
- Content modification/injection
|
|
17
|
+
- Web scraping extensions
|
|
18
|
+
- Authentication helpers
|
|
19
|
+
- Ad blockers and privacy tools
|
|
20
|
+
- Developer tools extensions
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Capabilities
|
|
25
|
+
|
|
26
|
+
- `manifest-v3`
|
|
27
|
+
- `content-scripts`
|
|
28
|
+
- `background-workers`
|
|
29
|
+
- `popup-ui`
|
|
30
|
+
- `storage-api`
|
|
31
|
+
- `messaging`
|
|
32
|
+
- `cross-browser`
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 1. Project Structure
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
extension/
|
|
40
|
+
├── manifest.json # Extension manifest
|
|
41
|
+
├── popup/
|
|
42
|
+
│ ├── popup.html # Popup UI
|
|
43
|
+
│ ├── popup.css
|
|
44
|
+
│ └── popup.js
|
|
45
|
+
├── background/
|
|
46
|
+
│ └── service-worker.js # Background script
|
|
47
|
+
├── content/
|
|
48
|
+
│ └── content.js # Content script
|
|
49
|
+
├── options/
|
|
50
|
+
│ ├── options.html # Settings page
|
|
51
|
+
│ └── options.js
|
|
52
|
+
├── icons/
|
|
53
|
+
│ ├── icon-16.png
|
|
54
|
+
│ ├── icon-48.png
|
|
55
|
+
│ └── icon-128.png
|
|
56
|
+
└── lib/
|
|
57
|
+
└── utils.js # Shared utilities
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 2. Manifest V3
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"manifest_version": 3,
|
|
67
|
+
"name": "My Extension",
|
|
68
|
+
"version": "1.0.0",
|
|
69
|
+
"description": "A helpful browser extension",
|
|
70
|
+
|
|
71
|
+
"permissions": [
|
|
72
|
+
"storage",
|
|
73
|
+
"activeTab",
|
|
74
|
+
"scripting"
|
|
75
|
+
],
|
|
76
|
+
|
|
77
|
+
"host_permissions": [
|
|
78
|
+
"https://*.example.com/*"
|
|
79
|
+
],
|
|
80
|
+
|
|
81
|
+
"action": {
|
|
82
|
+
"default_popup": "popup/popup.html",
|
|
83
|
+
"default_icon": {
|
|
84
|
+
"16": "icons/icon-16.png",
|
|
85
|
+
"48": "icons/icon-48.png",
|
|
86
|
+
"128": "icons/icon-128.png"
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
"background": {
|
|
91
|
+
"service_worker": "background/service-worker.js",
|
|
92
|
+
"type": "module"
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
"content_scripts": [
|
|
96
|
+
{
|
|
97
|
+
"matches": ["https://*.example.com/*"],
|
|
98
|
+
"js": ["content/content.js"],
|
|
99
|
+
"css": ["content/content.css"],
|
|
100
|
+
"run_at": "document_end"
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
|
|
104
|
+
"options_page": "options/options.html",
|
|
105
|
+
|
|
106
|
+
"icons": {
|
|
107
|
+
"16": "icons/icon-16.png",
|
|
108
|
+
"48": "icons/icon-48.png",
|
|
109
|
+
"128": "icons/icon-128.png"
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
"web_accessible_resources": [
|
|
113
|
+
{
|
|
114
|
+
"resources": ["images/*"],
|
|
115
|
+
"matches": ["https://*.example.com/*"]
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 3. Background Service Worker
|
|
124
|
+
|
|
125
|
+
```javascript
|
|
126
|
+
// background/service-worker.js
|
|
127
|
+
|
|
128
|
+
// Initialize on install
|
|
129
|
+
chrome.runtime.onInstalled.addListener((details) => {
|
|
130
|
+
if (details.reason === 'install') {
|
|
131
|
+
// Set default settings
|
|
132
|
+
chrome.storage.sync.set({
|
|
133
|
+
enabled: true,
|
|
134
|
+
theme: 'light',
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// Open onboarding page
|
|
138
|
+
chrome.tabs.create({ url: 'onboarding/welcome.html' });
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// Handle messages from content scripts and popup
|
|
143
|
+
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|
144
|
+
if (message.type === 'GET_DATA') {
|
|
145
|
+
fetchData(message.url).then(sendResponse);
|
|
146
|
+
return true; // Keep channel open for async response
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (message.type === 'SAVE_DATA') {
|
|
150
|
+
chrome.storage.local.set({ data: message.data });
|
|
151
|
+
sendResponse({ success: true });
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// Context menu
|
|
156
|
+
chrome.runtime.onInstalled.addListener(() => {
|
|
157
|
+
chrome.contextMenus.create({
|
|
158
|
+
id: 'saveToExtension',
|
|
159
|
+
title: 'Save to My Extension',
|
|
160
|
+
contexts: ['selection', 'link'],
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
chrome.contextMenus.onClicked.addListener((info, tab) => {
|
|
165
|
+
if (info.menuItemId === 'saveToExtension') {
|
|
166
|
+
const content = info.selectionText || info.linkUrl;
|
|
167
|
+
saveContent(content);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// Alarms for scheduled tasks
|
|
172
|
+
chrome.alarms.create('dailySync', { periodInMinutes: 1440 });
|
|
173
|
+
|
|
174
|
+
chrome.alarms.onAlarm.addListener((alarm) => {
|
|
175
|
+
if (alarm.name === 'dailySync') {
|
|
176
|
+
syncData();
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
async function fetchData(url) {
|
|
181
|
+
const response = await fetch(url);
|
|
182
|
+
return response.json();
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## 4. Content Script
|
|
189
|
+
|
|
190
|
+
```javascript
|
|
191
|
+
// content/content.js
|
|
192
|
+
|
|
193
|
+
// Wait for DOM ready
|
|
194
|
+
if (document.readyState === 'loading') {
|
|
195
|
+
document.addEventListener('DOMContentLoaded', init);
|
|
196
|
+
} else {
|
|
197
|
+
init();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function init() {
|
|
201
|
+
// Inject UI
|
|
202
|
+
injectUI();
|
|
203
|
+
|
|
204
|
+
// Observe DOM changes
|
|
205
|
+
observeDOM();
|
|
206
|
+
|
|
207
|
+
// Listen for messages
|
|
208
|
+
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|
209
|
+
if (message.type === 'HIGHLIGHT_TEXT') {
|
|
210
|
+
highlightText(message.text);
|
|
211
|
+
sendResponse({ success: true });
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function injectUI() {
|
|
217
|
+
const container = document.createElement('div');
|
|
218
|
+
container.id = 'my-extension-container';
|
|
219
|
+
container.innerHTML = `
|
|
220
|
+
<button id="ext-toggle">Toggle Extension</button>
|
|
221
|
+
<div id="ext-panel" class="hidden">
|
|
222
|
+
<h3>Extension Panel</h3>
|
|
223
|
+
<div id="ext-content"></div>
|
|
224
|
+
</div>
|
|
225
|
+
`;
|
|
226
|
+
|
|
227
|
+
document.body.appendChild(container);
|
|
228
|
+
|
|
229
|
+
// Add event listeners
|
|
230
|
+
document.getElementById('ext-toggle').addEventListener('click', togglePanel);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function observeDOM() {
|
|
234
|
+
const observer = new MutationObserver((mutations) => {
|
|
235
|
+
mutations.forEach((mutation) => {
|
|
236
|
+
if (mutation.type === 'childList') {
|
|
237
|
+
// Handle new content
|
|
238
|
+
processNewContent(mutation.addedNodes);
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
observer.observe(document.body, {
|
|
244
|
+
childList: true,
|
|
245
|
+
subtree: true,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Send message to background
|
|
250
|
+
function sendToBackground(data) {
|
|
251
|
+
chrome.runtime.sendMessage({ type: 'CONTENT_DATA', data });
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## 5. Popup UI
|
|
258
|
+
|
|
259
|
+
```html
|
|
260
|
+
<!-- popup/popup.html -->
|
|
261
|
+
<!DOCTYPE html>
|
|
262
|
+
<html>
|
|
263
|
+
<head>
|
|
264
|
+
<link rel="stylesheet" href="popup.css">
|
|
265
|
+
</head>
|
|
266
|
+
<body>
|
|
267
|
+
<div class="popup-container">
|
|
268
|
+
<h1>My Extension</h1>
|
|
269
|
+
|
|
270
|
+
<div class="toggle-section">
|
|
271
|
+
<label>
|
|
272
|
+
<input type="checkbox" id="enabled">
|
|
273
|
+
Enable Extension
|
|
274
|
+
</label>
|
|
275
|
+
</div>
|
|
276
|
+
|
|
277
|
+
<div class="stats">
|
|
278
|
+
<span id="count">0</span> items saved
|
|
279
|
+
</div>
|
|
280
|
+
|
|
281
|
+
<button id="action-btn" class="primary-btn">
|
|
282
|
+
Do Action
|
|
283
|
+
</button>
|
|
284
|
+
|
|
285
|
+
<div id="status"></div>
|
|
286
|
+
</div>
|
|
287
|
+
|
|
288
|
+
<script src="popup.js"></script>
|
|
289
|
+
</body>
|
|
290
|
+
</html>
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
```javascript
|
|
294
|
+
// popup/popup.js
|
|
295
|
+
document.addEventListener('DOMContentLoaded', async () => {
|
|
296
|
+
// Load saved settings
|
|
297
|
+
const { enabled = true, count = 0 } = await chrome.storage.sync.get(['enabled', 'count']);
|
|
298
|
+
|
|
299
|
+
document.getElementById('enabled').checked = enabled;
|
|
300
|
+
document.getElementById('count').textContent = count;
|
|
301
|
+
|
|
302
|
+
// Toggle handler
|
|
303
|
+
document.getElementById('enabled').addEventListener('change', async (e) => {
|
|
304
|
+
await chrome.storage.sync.set({ enabled: e.target.checked });
|
|
305
|
+
|
|
306
|
+
// Notify content scripts
|
|
307
|
+
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
|
|
308
|
+
chrome.tabs.sendMessage(tab.id, { type: 'TOGGLE', enabled: e.target.checked });
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
// Action button
|
|
312
|
+
document.getElementById('action-btn').addEventListener('click', async () => {
|
|
313
|
+
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
|
|
314
|
+
|
|
315
|
+
// Execute script in current tab
|
|
316
|
+
await chrome.scripting.executeScript({
|
|
317
|
+
target: { tabId: tab.id },
|
|
318
|
+
func: () => {
|
|
319
|
+
// This runs in the page context
|
|
320
|
+
const data = document.querySelector('.data')?.textContent;
|
|
321
|
+
return data;
|
|
322
|
+
},
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
showStatus('Action completed!');
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
function showStatus(message) {
|
|
330
|
+
const status = document.getElementById('status');
|
|
331
|
+
status.textContent = message;
|
|
332
|
+
setTimeout(() => status.textContent = '', 3000);
|
|
333
|
+
}
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## 6. Storage API
|
|
339
|
+
|
|
340
|
+
```javascript
|
|
341
|
+
// Sync storage (synced across devices)
|
|
342
|
+
await chrome.storage.sync.set({
|
|
343
|
+
settings: { theme: 'dark', notifications: true }
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
const { settings } = await chrome.storage.sync.get('settings');
|
|
347
|
+
|
|
348
|
+
// Local storage (device only, larger limit)
|
|
349
|
+
await chrome.storage.local.set({ largeData: [...] });
|
|
350
|
+
|
|
351
|
+
// Listen for changes
|
|
352
|
+
chrome.storage.onChanged.addListener((changes, area) => {
|
|
353
|
+
if (area === 'sync' && changes.settings) {
|
|
354
|
+
applySettings(changes.settings.newValue);
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
// Clear storage
|
|
359
|
+
await chrome.storage.local.clear();
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
## 7. Cross-Browser Support
|
|
365
|
+
|
|
366
|
+
```javascript
|
|
367
|
+
// Use webextension-polyfill for Firefox compatibility
|
|
368
|
+
// npm install webextension-polyfill
|
|
369
|
+
|
|
370
|
+
// Or use a wrapper
|
|
371
|
+
const browser = typeof chrome !== 'undefined' ? chrome : browser;
|
|
372
|
+
|
|
373
|
+
// Feature detection
|
|
374
|
+
function hasPermission(permission) {
|
|
375
|
+
return new Promise((resolve) => {
|
|
376
|
+
chrome.permissions.contains({ permissions: [permission] }, resolve);
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// Manifest differences
|
|
381
|
+
// manifest.json for Chrome
|
|
382
|
+
{
|
|
383
|
+
"background": {
|
|
384
|
+
"service_worker": "background.js"
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// manifest.json for Firefox
|
|
389
|
+
{
|
|
390
|
+
"background": {
|
|
391
|
+
"scripts": ["background.js"]
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
---
|
|
397
|
+
|
|
398
|
+
## 8. Publishing Checklist
|
|
399
|
+
|
|
400
|
+
| Platform | Store | Requirements |
|
|
401
|
+
|----------|-------|--------------|
|
|
402
|
+
| Chrome | Chrome Web Store | $5 dev fee, review 1-3 days |
|
|
403
|
+
| Firefox | AMO | Free, review 1-2 days |
|
|
404
|
+
| Edge | Edge Add-ons | Free, review 1-3 days |
|
|
405
|
+
|
|
406
|
+
### Pre-Submission
|
|
407
|
+
|
|
408
|
+
- [ ] Test all functionality
|
|
409
|
+
- [ ] Remove console.logs
|
|
410
|
+
- [ ] Minimize permissions (explain each)
|
|
411
|
+
- [ ] Privacy policy (if using user data)
|
|
412
|
+
- [ ] Screenshots (1280x800)
|
|
413
|
+
- [ ] Promotional images
|
|
414
|
+
- [ ] Description and changelog
|
|
415
|
+
|
|
416
|
+
---
|
|
417
|
+
|
|
418
|
+
## Related Skills
|
|
419
|
+
|
|
420
|
+
- `react-patterns` - React for popup UI
|
|
421
|
+
- `browser-automation` - Web automation
|
|
422
|
+
- `typescript-expert` - TypeScript support
|