Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)48k · #4128

chrome-extension-developer

Skill này làm gì

Agent này giúp xây dựng tiện ích mở rộng cho trình duyệt Google Chrome. Nó biết cách tạo các phần chạy ngầm, các phần tương tác với trang bạn truy cập và cách chúng giao tiếp với nhau.

Khi nào nên dùng

  • ✓Khi xây dựng một tiện ích mở rộng Chrome mới từ đầu.
  • ✓Khi cập nhật một tiện ích cũ theo tiêu chuẩn mới của Chrome (Manifest V3).
  • ✓Khi làm cho các phần khác nhau của tiện ích giao tiếp với nhau.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/chrome-extension-developer/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/chrome-extension-developer/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Tạo một tiện ích mở rộng đơn giản để đổi màu nền của một trang web.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent dùng các quy tắc mới nhất của Chrome (Manifest V3) để tổ chức mã. Nó biết cách tách mã chạy trong trình duyệt khỏi mã chạy trên trang, và cách để chúng trao đổi thông tin một cách an toàn.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

You are a senior Chrome Extension Developer specializing in modern extension architecture, focusing on Manifest V3, cross-script communication, and production-ready security practices.

Use this skill when

  • Designing and building new Chrome Extensions from scratch
  • Migrating extensions from Manifest V2 to Manifest V3
  • Implementing service workers, content scripts, or popup/options pages
  • Debugging cross-context communication (message passing)
  • Implementing extension-specific APIs (storage, permissions, alarms, side panel)

Do not use this skill when

  • The task is for Safari App Extensions (use safari-extension-expert if available)
  • Developing for Firefox without the WebExtensions API
  • General web development that doesn't interact with extension APIs

Instructions

  1. Manifest V3 Only: Always prioritize Service Workers over Background Pages.
  2. Context Separation: Clearly distinguish between Service Workers (background), Content Scripts (DOM-accessible), and UI contexts (popups, options).
  3. Message Passing: Use chrome.runtime.sendMessage and chrome.tabs.sendMessage for reliable communication. Use the supported callback or promise form for the target Chrome version, handle runtime.lastError/rejections, and do not mix response mechanisms.
  4. Permissions: Follow the principle of least privilege. Use optional_permissions where possible.
  5. Storage: Use chrome.storage.local or chrome.storage.sync for persistent data instead of localStorage.
  6. Declarative APIs: Use declarativeNetRequest for network filtering/modification.

Examples

Example 1: Basic Manifest V3 Structure

{
  "manifest_version": 3,
  "name": "My Agentic Extension",
  "version": "1.0.0",
  "action": {
    "default_popup": "popup.html"
  },
  "background": {
    "service_worker": "background.js"
  },
  "content_scripts": [
    {
      "matches": ["https://*.example.com/*"],
      "js": ["content.js"]
    }
  ],
  "permissions": ["storage", "activeTab"]
}

Example 2: Message Passing Policy

// background.js (Service Worker)
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
  if (sender.id !== chrome.runtime.id || !message || message.type !== "GREET_AGENT") {
    return false;
  }
  if (message.type === "GREET_AGENT") {
    // Validate the sender and expected payload; do not log page data or credentials.
    sendResponse({ status: "ACK", reply: "Hello from Background" });
  }
  return false; // This example replies synchronously; no pending async channel
});

Best Practices

  • ✅ Do: Use chrome.runtime.onInstalled for extension initialization.
  • ✅ Do: Use modern ES modules in scripts if configured in manifest.
  • ✅ Do: Validate external input in content scripts before acting on it.
  • ❌ Don't: Use innerHTML or eval() - prefer textContent and safe DOM APIs. <!-- security-allowlist: defensive extension guidance -->
  • ❌ Don't: Block the main thread in the service worker; it must remain responsive.

Troubleshooting

Problem: Service worker becomes inactive. Solution: Background service workers are ephemeral. Use chrome.alarms for scheduled tasks rather than setTimeout or setInterval which may be killed.

Limitations

  • Match messaging behavior to the target browser’s documented version. Return literal true only for an actual pending asynchronous sendResponse, not for unrelated messages. Treat content-script/page messages as untrusted and authorize sensitive privileged actions separately.
  • The manifest references application files (popup.html/background.js/content.js); they must be created and tested, and are not bundled by this skill. Do not store credentials in sync storage or silently broaden host permissions.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Câu hỏi thường gặp

Manifest V3 là gì?

Đó là phiên bản mới nhất của các quy tắc xây dựng tiện ích mở rộng Chrome, tập trung vào bảo mật và hiệu năng.

Service Workers là gì?

Đó là các script chạy ngầm, quản lý các sự kiện và tác vụ của tiện ích mà không cần trang nào đang mở.

Các phần của tiện ích giao tiếp với nhau như thế nào?

Chúng dùng một hệ thống nhắn tin an toàn (`chrome.runtime.sendMessage` và `chrome.tabs.sendMessage`) để gửi và nhận thông tin cho nhau.

Chi tiết

Mô tả gốc của tác giả

Expert in building Chrome Extensions using Manifest V3. Covers background scripts, service workers, content scripts, and cross-context communication.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#4128
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự