-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor content scripts into platform adapter pattern #10
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or requestextensionChrome/browser extensionChrome/browser extension
Description
What
Refactor the content script architecture so each platform (Twitter, YouTube, Reddit) implements a shared adapter interface. Currently content.js is Twitter-specific.
From ROADMAP.md - Phase 3.4.
Problem
Adding YouTube and Reddit support means duplicating the classification flow, cache logic, and treatment application across multiple content scripts. This will become hard to maintain.
Proposed Architecture
extension/
platforms/
adapter.js # Shared interface: extractContent(), applyTreatment()
twitter.js # Twitter-specific DOM selectors and extraction
youtube.js # YouTube-specific DOM selectors and extraction
reddit.js # Reddit-specific DOM selectors and extraction
content.js # Shared logic: observe, classify, treat (uses adapter)
Each adapter implements:
getContentElements()- Find new content in the DOMextractText(element)- Pull classifiable text from an elementapplyTreatment(element, result)- Apply blur/tag/hide to an elementgetElementId(element)- Unique key for caching
Why
- Adding a new platform becomes: implement one adapter file
- Shared classification and caching logic stays DRY
- Testing is easier with a clear interface
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestextensionChrome/browser extensionChrome/browser extension