Skip to content

Conversation

@Octech2722
Copy link

[DRAFT] Manifest V3 Migration for Web Clipper

Status: 🚧 Work in Progress - Not ready for review
Progress: ~70% complete (core features done, cleanup pending)

What This PR Does

Migrates the Trilium Web Clipper from Manifest V2 to Manifest V3 to comply with Chrome's deprecation timeline (January 2025).

Current Status

✅ Completed

  • Core architecture (service worker, storage, messaging)
  • Content capture (selection, page, link, screenshot, image)
  • Readability + DOMPurify + Cheerio pipeline
  • Centralized logging system
  • Theme system (light/dark/system)
  • Basic UI (popup, settings, logs)
  • Context menus and keyboard shortcuts

🚧 In Progress

  • Screenshot cropping implementation
  • Image processing for full-page captures
  • Code cleanup and deduplication
  • Final documentation polish

📋 TODO Before Ready

  • Complete remaining features (see checklist)
  • Comprehensive testing
  • Documentation finalization
  • Code review prep

Questions for Maintainers

  1. Approach: Is the service worker architecture acceptable? Any concerns with the current structure?
  2. Documentation: What level of documentation is expected? (I have architecture docs, migration patterns, etc.)
  3. Testing: Manual testing sufficient, or are automated tests expected?
  4. Timeline: Is there urgency given MV2 deprecation timeline?

Notes

  • This is my first major Chrome extension and first PR to this repo, so feedback welcome!
  • I'm actively working on this and updating regularly
  • Will mark ready for review when testing and cleanup complete

Related

Octech2722 and others added 30 commits September 29, 2025 19:03
- Complete Manifest V3 conversion for Chrome extension future compatibility
- Add progressive status notifications with real-time feedback
- Optimize performance with non-blocking async operations
- Convert to ES module architecture with service worker
- Replace browser.* APIs with chrome.* throughout
- Add smart content script injection (dynamic, only when needed)
- Enhance error handling with graceful degradation
- Preserve all existing functionality while improving UX
- Faster save operations with clean error-free console logs

Breaking Changes: None - fully backward compatible
Performance: Significantly improved save operation speed
UX: Added real-time status updates during save operations
…pment files

- Improve README.md formatting and spacing
- Remove development/debugging files (MANIFEST_V3_CONVERSION.md, PULL_REQUEST.md, background-v2.js, verify-conversion.sh)
- Clean up project structure as requested in PR review
- Manifest V3 configuration with proper permissions
- TypeScript + esbuild build system
- npm dependencies (Readability, DOMPurify, Cheerio)
- Build configuration (IIFE bundling, watch mode)
- Shared TypeScript type definitions

Foundation for Trilium Web Clipper Manifest V3 migration.
Components:
- CentralizedLogger static class for log aggregation
- Logger class with source context (background/content/popup/options)
- Persistent storage in chrome.storage.local (up to 1000 entries)
- Log viewer UI with filtering, search, and export
- Survives service worker restarts

Critical for MV3 debugging where service workers terminate frequently.
Provides unified debugging across all extension contexts.
Features:
- ThemeManager with three modes (light/dark/system)
- CSS custom properties for semantic colors
- Persistent storage via chrome.storage.sync
- Real-time OS theme detection and updates
- Event subscription system for theme changes

Provides professional theming across all UI components.
System mode automatically follows OS preference.
Service Worker Architecture:
- Event-driven, stateless (MV3 compatible)
- Message passing with structured error handling
- Chrome storage for state persistence

Capture Features:
- Save Selection (with image processing and base64 embedding)
- Save Page (Readability → DOMPurify → Cheerio pipeline)
- Save Link (basic URL + title)
- Save Screenshot (full page capture, cropping pending)
- Save Image (download and embed as base64)

Additional Features:
- Duplicate note detection with user choice dialog
- Context menu initialization on install
- Keyboard shortcut handlers
- Trilium API communication (create notes, search)
- Connection testing and validation

Uses centralized logging throughout.
No global state - all persistence via chrome.storage.
Content Script Features:
- Declarative injection via manifest
- Selection extraction and HTML processing
- Image discovery and base64 conversion
- Message passing to service worker

Duplicate Note Notification
- Gives a large visual notification if an exisitng note is found in Trilium
- Can be toggled on/off via settings
- On by default

Runs in page context with proper CSP compliance.
Features:
- Quick action buttons (Selection, Page, Link, Screenshot, Image)
- Connection status indicator with real-time updates
- Theme toggle (system/light/dark) with visual feedback
- Navigation to Settings and Logs pages
- Keyboard shortcuts display
- Full theme system integration

Entry point for most user interactions.
Initializes theme on load and persists preference.
Uses centralized logging for debugging.
Configuration Options:
- Trilium server URL with validation
- Authentication token (secure storage)
- Connection testing with detailed feedback
- Save format selection (HTML/Markdown/Both)
- Parent note selection (future enhancement)
- Theme preferences with live preview

Settings Persistence:
- chrome.storage.local for connection config
- chrome.storage.sync for user preferences
- Automatic validation on save

Full theme system integration.
Architecture Documentation:
- System component overview (logging, theme, build)
- Content processing pipeline details
- File structure and organization
- Message flow diagrams
- Storage strategy (local vs sync)
- MV3 constraints and solutions

Migration Patterns:
- 8 common MV2 → MV3 migration patterns
- TypeScript examples with proper error handling
- Chrome API usage examples
- Best practices for each scenario

Serves as reference to avoid re-explaining systems repeatedly.
Copilot Integration:
- Streamlined instructions (70% shorter than original)
- Task templates for common operations
- Three-tier usage strategy (free/strategic/manual)
- Optimized for GitHub Copilot Basic tier limits

Development Resources:
- Common task workflows with time estimates
- Feature parity checklist with priorities
- Debugging and troubleshooting guides
- Testing scenarios and checklists
- Code quality standards

Workflow Optimization:
- Efficient Copilot task budgeting
- Real-world implementation examples
- Performance and success metrics
- Project completion roadmap

Reduces repetitive context in prompts.
Maximizes limited Copilot task budget.
- Extension icons (16x16, 48x48, 128x128)
- Static assets for UI
- Build configuration assets

Required for extension manifest and Chrome Web Store.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web Clipper needs update to adapt to Chrome manifest V3

1 participant