Skip to content

E20C1/Chrome-Extension-Template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Chrome Extension Template πŸš€

Read this in other languages: ζ—₯本θͺž

License: MIT Manifest: v3 PRs Welcome

Chrome Extension Icon

A lightweight and accessible template for easily developing modern Chrome extensions

πŸ“‹ Table of Contents

Features πŸ’―

πŸŒ™ ⟷ β˜€οΈ
Theme Support
πŸ”„
Auto-Save
πŸ›‘οΈ
Minimal Permissions
πŸ“¦
Data Management
β™Ώ
Accessible UI
πŸ”Œ
Manifest V3
  • Manifest V3 Compatible: Uses an event-driven extension service worker
  • Minimal Permissions: Requests only storage and no default site access
  • Modular Design: Separates shared settings, popup, options, background, and optional examples
  • Theme Support: Supports system, light, and dark themes
  • Data Management: Imports and exports validated settings backups
  • Auto-Save Functionality: Saves and synchronizes settings in real time
  • Accessible UI: Includes semantic controls, visible focus, and 44px interaction targets
  • Zero Dependencies: Uses browser and Node.js built-in APIs only

File Structure πŸ“

Chrome-Extension-Template/
β”‚
β”œβ”€β”€ manifest.json              # Extension configuration
β”‚
β”œβ”€β”€ shared/
β”‚   β”œβ”€β”€ settings.js            # Settings schema and storage helpers
β”‚   β”œβ”€β”€ ui.js                  # Theme and localization helpers
β”‚   └── ui.css                 # Shared accessible UI styles
β”‚
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ background.js          # Extension service worker
β”‚   β”œβ”€β”€ validate.mjs           # Source and configuration checks
β”‚   └── build.mjs              # Runtime-only build script
β”‚
β”œβ”€β”€ popup/                     # Toolbar popup
β”œβ”€β”€ options/                   # Extension options page
β”œβ”€β”€ _locales/                  # English and Japanese messages
β”œβ”€β”€ examples/content-script/   # Optional page-access example
β”œβ”€β”€ tests/                     # Node.js built-in tests
β”‚
└── assets/
    └── icons/                 # 16, 48, and 128px icon files

System Architecture πŸ”„

Component Role Features
πŸ”„ Service Worker Event Processing Installation, startup, and badge updates
πŸ–₯️ Popup UI Quick Settings Enable/disable control and status display
βš™οΈ Options UI Detailed Settings Theme, badge, backup, and reset controls
πŸ’Ύ Chrome Storage Data Storage Synchronized settings persistence
βš™οΈ Component Interaction Flow βš™οΈ

Popup UI ⟷ Shared Settings ⟷ Chrome Storage
⬆️ ⬇️
Options UI ⟷ Shared Settings
⬆️ ⬇️
Service Worker ⟷ Chrome Action

The base template does not inject code into web pages. A narrowly scoped content-script example is available in examples/content-script/ when page access is required.

Installation πŸ”§

Requirements

  • Google Chrome 102 or later
  • Developer mode enabled
  • Node.js 20 or later only when running tests or builds

Steps

  1. Clone the repository:

    git clone https://github.com/E20C1/Chrome-Extension-Template.git
    cd Chrome-Extension-Template
  2. Load the extension in Chrome:

    • Open chrome://extensions in Chrome
    • Turn on Developer mode
    • Click Load unpacked
    • Select the cloned directory
πŸ” Access chrome://extensions
πŸ”§ Turn on "Developer mode" in the top right
πŸ“¦ Click "Load unpacked" and select the repository
βœ… Verify the extension has loaded successfully

Usage πŸ‘†

Basic Features

  • Enable/Disable Extension: Toggle the extension state from the popup
  • Theme Switching: Select system, light, or dark mode on the options page
  • Status Badge: Show or hide the ON / OFF toolbar badge
  • Automatic Saving: Apply and synchronize every settings change immediately

Data Management

  • Export Settings: Download the current settings as a versioned JSON backup
  • Import Settings: Restore a validated JSON backup up to 256KB
  • Reset Settings: Restore safe defaults after confirmation

Customization Guide πŸ› οΈ

Editing Extension Information

Update these messages in both _locales/en/messages.json and _locales/ja/messages.json:

{
  "extensionName": { "message": "Your Extension Name" },
  "extensionDescription": { "message": "Your extension description" },
  "actionTitle": { "message": "Open Your Extension" }
}

Permission Settings

Add only permissions required by a current feature to respect user privacy:

"permissions": [
  "storage"
]

For page access, start with examples/content-script/README.md and use the narrowest possible match pattern. Do not add <all_urls> for future or hypothetical features.

Adding Settings

  1. Add a default value and normalization rule to shared/settings.js
  2. Add localized labels to both locale files
  3. Add a semantic control to the popup or options page
  4. Add or update a test in tests/

Adding Icons

Add icons of the following sizes to the assets/icons/ directory:

  • icon16.png (16x16 px)
  • icon48.png (48x48 px)
  • icon128.png (128x128 px)

Key Features ✨

  • Simple Design: Easy-to-understand structure for beginners
  • Minimal Permissions: No host or tab access in the base template
  • Modern UI: Responsive popup and single-column options layout
  • Fast Performance: No frameworks, remote assets, or runtime dependencies
  • Accessible Foundation: Keyboard focus, reduced motion, forced colors, and localized labels

Development Tips πŸ’‘

  1. Run Checks: Use npm test to validate settings, Manifest, i18n, HTML, CSS, and icons
  2. Create a Build: Use npm run build to copy runtime files into dist/
  3. Reload Changes: Use the refresh button on chrome://extensions
  4. Debug the Worker: Open the service worker inspector from the extension details page
  5. Inspect Storage: Settings are stored in chrome.storage.sync
npm test
npm run build

GitHub Actions runs the same checks for every push and pull request.

How to Contribute 🀝

  1. Fork the repository 🍴
  2. Add a focused feature or improvement ✨
  3. Run the tests and build locally βœ…
  4. Submit a pull request πŸš€

Contribution Guidelines:

  • Follow the existing code style πŸ“
  • Request only permissions required by the feature πŸ›‘οΈ
  • Write clear commit messages πŸ“
  • Explain the reason and impact of each change πŸ”

Technical Specifications πŸ’»

  • Manifest Version: Manifest V3
  • Minimum Chrome Version: Chrome 102
  • JavaScript: Standard ES modules and modern browser APIs
  • Service Worker: Event-driven background processing
  • Storage API: chrome.storage.sync restricted to trusted extension contexts
  • Internationalization: Chrome i18n with English and Japanese locales
  • Dependencies: No runtime or npm package dependencies
  • Build Output: Runtime-only files in dist/

Todo πŸ“

  • Add icon files
  • Add unit tests and source validation
  • Set up build automation and GitHub Actions
  • Add an optional onboarding-page example
  • Add cross-browser packaging examples
  • Add automated end-to-end extension tests

License πŸ“„

MIT License


Β© 2026 Chrome Extension Template
Made with ❀️ by E20C1

About

Modern Chrome Extension template with Manifest V3 support, ready-to-use components and developer configurations for quick extension development.

Topics

Resources

License

Stars

2 stars

Watchers

1 watching

Forks

Contributors