Learn-skills.dev extension-functions-best-practices

Best practices for implementing browser extension features across 13 categories. Reference this skill when developing video, audio, image, translation, download, userscript, AI (including Chrome built-in AI / Gemini Nano), ad-blocker, theme, email, game, password manager, or Web3 wallet features.

install
source · Clone the upstream repo
git clone https://github.com/NeverSight/learn-skills.dev
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/NeverSight/learn-skills.dev "$T" && mkdir -p ~/.claude/skills && cp -r "$T/data/skills-md/addfox/skills/extension-functions-best-practices" ~/.claude/skills/neversight-learn-skills-dev-extension-functions-best-practices && rm -rf "$T"
manifest: data/skills-md/addfox/skills/extension-functions-best-practices/SKILL.md
source content

Extension Functions Best Practices

Implementation guidance for browser extension features across 13 categories. Each category includes reference open-source projects and links to detailed implementation guides.

When to Use

  • Building extension features in any supported category
  • Looking for proven patterns and reference implementations
  • Choosing libraries and APIs for specific functionality
  • Understanding permission requirements

How Reference Projects Are Chosen

  • Verifiable: Prefer projects you can install from a store, or build into a loadable extension from GitHub, with real Issues/Releases.
  • Behavior-aligned: Table Highlights describe user-visible behavior (e.g. “merge HLS segments”) rather than only “call the downloads API”.
  • Download / streaming: Tutorial-style
    chrome.downloads
    + an
    m3u8
    URL is often not enough for a playable file; treat rules/download.md (“Reality check & common pitfalls”) and repos such as Cat Catch, Live Stream Downloader, and Video DownloadHelper as the ground truth.

Feature Categories

1. Video

Common Features: Enhancement (rotation, speed, zoom), download (media sniffing, M3U8/MPD), screen recording

Reference ProjectsTypeHighlights
Video RollEnhancementRotation, zoom, filters, VR mode (in-page
<video>
UX)
Cat CatchDownloadSniffing, M3U8/MPD parsing, handoff to N_m3u8DL-RE and similar (high activity)
Live Stream DownloaderDownloadIn-extension HLS detection and multi-threaded merge to disk (store build for comparison)
Video DownloadHelperDownloadGeneral sniffing + vdhcoapp companion (production-grade OSS core)
HLS DownloaderDownloadHLS detection and download flow
ScreenityRecordingScreen/camera recording with annotations

Key Libraries: Mediabunny (lightweight media processing), Native MediaRecorder API

Implementation Guide: rules/video.md


2. Audio

Common Features: Volume boost, per-tab volume control, audio visualization

Reference ProjectsTypeHighlights
Better Volume BoosterVolume BoostDomain memory, mono/stereo toggle
Tab VolumeVolume ControlPer-tab control with hotkeys

Key APIs: Web Audio API (AudioContext, GainNode), chrome.tabCapture

Implementation Guide: rules/audio.md


3. Image

Common Features: Batch download, hover preview, background image extraction, screenshot (visible/full page/element)

Reference ProjectsTypeHighlights
Image DownloaderDownloadBatch download with filtering
Pic-GrabberDownloadShadow DOM, lazy-load support
screenshot-extensionScreenshotFull-page / region capture flow (MIT)
webpage-screenshotScreenshotClassic full-page capture (ISC)

Key Techniques: Canvas processing, Shadow DOM traversal, chrome.tabs.captureVisibleTab

Libraries: html2canvas, dom-to-image (for full page screenshots)

Implementation Guide: rules/image.md


4. Translation

Common Features: Page translation, bilingual display, select-to-translate, PDF translation

Reference ProjectsTypeHighlights
Immersive TranslatePage TranslationBilingual, PDF support
Read FrogAI TranslationContext-aware explanations
OpenAI TranslatorAI TranslationChatGPT-based translation

Key Libraries: Readability.js (content extraction), PDF.js

Implementation Guide: rules/translation.md


5. Download

Common Features: Resource sniffing, batch download, external downloader integration

Reference ProjectsTypeHighlights
Cat CatchSniffingResource sniffing, M3U8/MPD, external downloaders (end-to-end “finish the file”)
Live Stream DownloaderHLSMerge segments in-extension vs.
chrome.downloads
saving only the playlist
Video DownloadHelperSniffing + appBrowser + native companion
Stream DetectorDetectionExport cookies for aria2 / yt-dlp, etc.
Turbo Download Manager v2ManagerMulti-connection, resume (direct URLs / files)

External Tools: N_m3u8DL-RE, yt-dlp, aria2

Implementation Guide: rules/download.md


6. Userscript

Common Features: Script manager, page enhancement, automation

Reference ProjectsTypeHighlights
TampermonkeyManagerMost popular, cloud sync
ViolentmonkeyManagerOpen source, lightweight
GreasemonkeyManagerFirefox native

Dev Tools: vite-plugin-monkey - Modern development with HMR

Implementation Guide: rules/userscript.md


7. AI

Common Features: Sidebar chat, page summarization, reading assistant, prompt enhancement

Reference ProjectsTypeHighlights
BrainyAISidebarMulti-model sidebar (check Issues/Releases for maintenance)
ChatGPT BoxIntegrationSelection, summarize, site integrations (GPL-3.0, buildable reference)
ScrollNavigationLLM web UI navigation helpers (MIT)

Chrome built-in AI (on-device): Extensions and AI — Prompt, Summarizer, Translator, Language Detector, Writer, Rewriter, Proofreader (status table). Official samples: ai.gemini-on-device, ai.gemini-on-device-summarization.

Built-in AI implementation guide: rules/chrome-built-in-ai.md

Key APIs: OpenAI API, Google Gemini API, Anthropic Claude API, Ollama (local); built-in:

LanguageModel
(Prompt API),
Summarizer
,
Translator
,
LanguageDetector
, etc. (docs)

SDKs: Vercel AI SDK, LangChain.js, LlamaIndex (TypeScript); typings:

@types/dom-chromium-ai

Implementation Guide: rules/ai.md


8. Ad Blocker

Common Features: Ad blocking, tracker blocking, privacy protection, malware protection

Reference ProjectsTypeHighlights
uBlock OriginAd BlockerEfficient, low resource
Privacy BadgerPrivacyAlgorithmic tracker detection

Filter Lists: EasyList, EasyPrivacy, uBlock filters

Implementation Guide: rules/adblocker.md


9. Theme

Common Features: Dark mode, custom CSS injection, theme management

Reference ProjectsTypeHighlights
Dark ReaderDark ModeSmart inversion, dynamic themes
StylusCSS ManagerUserCSS support, cloud sync

NPM Package:

darkreader
- Use in your projects

Implementation Guide: rules/theme.md


10. Email

Common Features: Email notifications, quick preview, multi-account support

Reference ProjectsTypeHighlights
Mail Checker PlusGmailUnread badge, list preview, mark read, etc. (GPL-3.0, Gmail API reference)
gmail-api-chrome-extensionGmail APIMinimal OAuth + Gmail REST sample (MIT, auth flow learning)

Key APIs: Gmail API, chrome.identity

Implementation Guide: rules/email.md


11. Game

Common Features: WebAssembly modification, memory editing, auto-click

Reference ProjectsTypeHighlights
CetusWASM HackingMemory search, freeze, breakpoints

Note: Use responsibly, only on single-player/offline games

Implementation Guide: rules/game.md


12. Password Manager

Common Features: Password storage, auto-fill, password generation, encryption

Reference ProjectsTypeHighlights
BitwardenFull FeaturedCloud sync, cross-platform
KeePassXC-BrowserIntegrationLocal password database

Key APIs: Web Crypto API (AES-256-GCM, PBKDF2)

Implementation Guide: rules/password-manager.md


13. Web3 Wallet

Common Features: Wallet management, transaction signing, DApp connection, multi-chain

Reference ProjectsTypeHighlights
MetaMaskWalletIndustry standard, EIP-1193
RabbyWalletMulti-chain, transaction simulation
RainbowWalletExtension source (distinct from mobile app repo)

Key Libraries: ethers.js, viem

Standards: EIP-1193 (Provider API), EIP-712 (Typed Data)

Implementation Guide: rules/web3.md


Library Choices Summary

DomainPreferredAvoid (in extension)
Video/Audio processingMediabunnyFFmpeg.wasm (large, slow)
RecordingNative MediaRecorderHeavy encoder libs
Screenshotschrome.tabs.captureVisibleTabLarge image libs
AIRemote API callsLarge local models (WASM/ONNX)
TranslationRemote APIBundled NLP models
Userscript executionSandboxed iframeDirect eval()
Downloadchrome.downloads + streamIn-memory buffering
EncryptionWeb Crypto APICustom crypto implementations

Permissions Quick Reference

FeatureKey Permissions
Video Download
downloads
,
webRequest
/
declarativeNetRequest
Audio Processing
tabCapture
,
offscreen
(MV3)
Image Download
downloads
,
activeTab
Translation
activeTab
,
storage
Userscript
<all_urls>
,
storage
AI
sidePanel
,
storage
Ad Blocker
declarativeNetRequest
,
<all_urls>
Theme
activeTab
,
scripting
Email
identity
,
notifications
Password Manager
storage
,
activeTab
,
scripting
Web3
storage
,
activeTab
,
scripting

Additional Resources