Browser Extension — Clip to CommonPlace
Save articles, quotes, and links from anywhere on the web to your CommonPlace drafts.
Overview
The "Clip to CommonPlace" extension is a vanilla JavaScript browser extension using Manifest V3. It lets you clip web content directly into your CommonPlace account without leaving the page.
Source: extension/
Features
- Clip full pages — Save the current page's URL, title, and selected metadata
- Clip selections — Highlight text and clip just that excerpt
- Keyboard shortcuts —
Alt+Shift+C(clip page),Alt+Shift+S(clip selection) - Context menu — Right-click to clip
- Offline queue — Clips are queued when offline and synced when reconnected
- oEmbed support — Rich previews for supported URLs
Architecture
extension/
├── manifest.json # MV3 manifest (Chrome)
├── package.json # npm scripts for build/watch
├── build.sh # Build Chrome/Firefox zips
├── watch.sh # Auto-rebuild on file changes
├── assets/ # Extension icons (16, 32, 48, 128px)
├── background/
│ └── service-worker.js # Background service worker
├── content/
│ └── content-script.js # Injected content script
├── lib/
│ ├── api.js # Supabase API calls
│ ├── auth.js # Authentication
│ ├── config.js # Configuration
│ ├── oembed.js # oEmbed resolution
│ ├── offline-queue.js # Offline clip queuing
│ └── utils.js # Shared utilities
├── options/
│ ├── options.html # Options page
│ ├── options.css
│ └── options.js
└── popup/
├── popup.html # Extension popup
├── popup.css
├── popup.js
└── auth.js # Popup auth flow
Build Scripts
build.sh
Packages the extension into distributable zip files.
# Build Chrome zip (default)
bash build.sh
# Build Firefox zip (patches manifest for MV3 compatibility)
bash build.sh firefox
# Build both
bash build.sh all
Output goes to extension/dist/:
commonplace-chrome-v1.0.0.zipcommonplace-firefox-v1.0.0.zip
Cross-platform zip: The script tries zip first, then PowerShell Compress-Archive (Windows), then 7z.
Firefox manifest patching: The Firefox build automatically:
- Replaces
service_workerwithscriptsarray (Firefox MV3 requirement) - Adds
browser_specific_settings.geckowith addon ID
watch.sh
Polls for file changes every 2 seconds and rebuilds automatically.
# Watch and rebuild Chrome zip
bash watch.sh
# Watch and rebuild Firefox zip
bash watch.sh firefox
npm scripts
npm run build # bash build.sh
npm run build:firefox # bash build.sh firefox
npm run watch # bash watch.sh
Development
For local development, load the extension unpacked directly from extension/ in your browser's extension manager. The build scripts are for creating distributable packages.
Chrome
- Go to
chrome://extensions/ - Enable "Developer mode"
- Click "Load unpacked"
- Select the
extension/directory
Firefox
- Go to
about:debugging#/runtime/this-firefox - Click "Load Temporary Add-on"
- Select
extension/manifest.json
Permissions
activeTab— Access to the current tab when the user clicks the extensionstorage— Store auth tokens and settingscontextMenus— Right-click context menu integrationnotifications— Show clip confirmation notificationsalarms— Schedule offline queue sync- Host permissions for Supabase API endpoints