"The first six tracks built the skeleton on cooperative pages. Track 7 is the prosthetic for pages that fight back — heavy frameworks, dynamic re-renders, SPAs that swap content faster than you can attach a handler. Lesson 1 maps the toolkit, the next six lessons sharpen each tool."
What Counts as a DOM Tool
Anything that bridges your content script and the page's actual structure, beyond the basics from Track 3. The tools split into three families:
- Extraction — pulling clean, structured data out of messy markup. Readability, schema.org parsing, OpenGraph, custom CSS-selector libraries.
- Capture — recording what the user is looking at right now. Selection text, screenshots, scroll positions, viewport dimensions.
- Mutation — modifying the page on the user's behalf. Filling inputs, dispatching synthetic events, injecting overlays, scrolling into view.
ClipDeck v1 leans on extraction (article body for big clips) and capture (selection + screenshot). v2 will add mutation (auto-fill saved snippets back into pages). Track 7 covers all three families because the muscles are the same.
The 'Real-World' Adjustment
The tools differ from textbook DOM work because real-world pages are hostile to extensions in ways that test code is not:
- Framework opacity. React, Vue, Svelte own the DOM. Their components re-render on state change, demolishing whatever overlay you injected.
- Synthetic event tracking. Framework form inputs track their own state via setters; setting
input.valuedirectly doesn't update the framework's idea of the input. - Lazy loading. Article images, comments, related posts load as the user scrolls. Code that reads at
DOMContentLoadedmisses everything after that moment. - CSP and CSS-isolation. Strict CSPs on many sites refuse extension stylesheets unless you inject them as adopted stylesheets via constructable stylesheets.
- Shadow DOM. Open shadow roots are queryable; closed ones aren't. Sites use them increasingly for components, and your querySelector returns nothing.
The 'Trust the User' Adjustment
The page is the user's space. Any mutation you make has to respect:
- Preview before commit. Show what you're about to do, let the user confirm or back out. Track 7 Lesson 6 covers this in depth.
- Undo within a window. Destructive actions (delete clip, fill form) earn a 5-second undo. Beyond that they finalize.
- Visible attribution. If you mutate a form input, leave a small marker (border tint, side label) so the user remembers ClipDeck did it.
- Don't surprise. No auto-fill, no auto-save, no automatic anything that the user did not initiate.
The Bundle Question
Some tools (Readability) come from third-party libraries. Three ways to bring them in:
- Vendor — drop the source file into your extension, commit it. Simple, auditable, no build step needed for vanilla JS libraries.
- npm + bundler — modern setup. esbuild / Rollup / Vite produces a single bundled content.js. Required for anything with ES module imports.
- Dynamic import — Chrome 96+ supports ES module imports in content scripts via the
type: 'module'field. Lets you skip the bundler for simple cases.
ClipDeck v1 vendors a single Readability.js file and skips the bundler. Track 8 (packaging) covers the bundler path for when you grow past a one-file approach.
What This Track Adds
Six tools in six lessons:
- Lesson 2 — Readability.js for article body extraction.
- Lesson 3 — Selection and Range API deep dive (beyond toString).
- Lesson 4 — chrome.tabs.captureVisibleTab + canvas crop for selection screenshots.
- Lesson 5 — The React-friendly input-fill trick.
- Lesson 6 — Preview-and-confirm pattern.
- Lesson 7 — ClipDeck CRUD-U and CRUD-D, with inline edit and undo.
By the end ClipDeck handles the realistic case where the user reads a New York Times article, highlights three paragraphs, hits Ctrl+Shift+K, sees a preview of what's about to be saved, confirms, then edits the clip's title in the side panel and deletes a duplicate from earlier — all without losing their place on the page.