webext-core

Provide utilities for cross-context RPC, type-safe messaging, and browser extension testing.

9.0k|629|Updated Apr 16, 2025
One-click install
npx skills add https://github.com/mengxi-ream/read-frog --skill webext-core
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: webext-core
Source: https://github.com/mengxi-ream/read-frog/tree/main/.agents/skills/webext-core
Command: npx skills add https://github.com/mengxi-ream/read-frog --skill webext-core

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Utilities for browser extensions aim to reduce the complexity of building robust, cross-context functionality by providing ready-made components for inter-context RPC, type-safe messaging, URL pattern matching, test-friendly fake browser APIs, job scheduling, and shadow DOM isolation.

Core Features & Use Cases

  • Cross-context RPC via proxy-service to call background implementations from popup/content/scripts
  • Type-safe messaging with defineExtensionMessaging and defineWindowMessaging
  • URL pattern matching utilities using MatchPattern
  • In-memory fake browser API for unit tests to simulate browser APIs
  • Background job scheduling with defineJobScheduler
  • Shadow DOM isolation containers for content-script UIs via createIsolatedElement
  • Optional storage wrappers with type safety

Quick Start

Install the core utilities in your extension and start by exposing a background service with registerService, then call it from a popup or content script using createProxyService.

Frequently Asked Questions about webext-core

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle cross-context messaging in a browser extension?

Type-safe messaging utilities enable structured communication between background scripts, popups, and content scripts. Using defineExtensionMessaging ensures type safety for cross-context browser extension messaging without manual serialization.

What is the best way to call background script functions from a popup?

Using a proxy-service is the best way to call background functions from a popup. You expose implementations with registerService in the background and invoke them remotely via createProxyService in the popup or content script.

How do I simulate browser APIs for extension unit tests?

You simulate browser APIs for extension unit tests using an in-memory fake browser. This test-friendly environment allows you to mock browser behaviors and validate extension logic without launching a real browser instance.

Can I isolate content script UIs using shadow DOM?

Yes, you can isolate content script UIs using shadow DOM. The createIsolatedElement utility generates shadow DOM containers, preventing CSS or JavaScript conflicts between your extension interface and the host web page.

How do I schedule background jobs in a browser extension?

You schedule background jobs in a browser extension using defineJobScheduler. This utility manages background job scheduling, allowing you to execute timed or recurring tasks reliably within the extension background context.

Does this utility suite provide URL pattern matching for content scripts?

Yes, the utility suite provides URL pattern matching for content scripts via MatchPattern. It evaluates URLs against standard browser extension patterns to conditionally apply scripts or logic based on the current page.