How madhumithra-r/focuslens works
FocusLens is a local-first Chrome extension that monitors browsing behavior, calculates a rule-based distraction score, and offers a check-in when scrolling crosses its configured threshold. Its main workflow runs in the page content script: observe scrolling and active time, score behavior, then blur the page and present a learning-or-break prompt. The popup provides live metrics and controls; the background worker handles settings and persisted statistics. The sampled excerpts do not show all message types or the complete scoring and dismissal logic, so those links are documented where possible and otherwise omitted.
Main entry points: popup.js Dashboard controller · background.js Background worker · content.js Blur and check-in · popup.html Popup dashboard
Components 11
Page monitoring
- Scroll detection
content.js - Active-time tracking
content.js - Rule-based scoring
content.js
Check-in intervention
- Blur and check-in
content.js
Popup dashboard
- Popup dashboard
popup.html - Dashboard controller
popup.js
Background and storage
- Background worker
background.js - Local statistics and settings
background.js - Extension badge
Other components
- User
- Web page
Connections 18
- User → Web page: browses
README.md - Web page → Scroll detection: emits scroll events
content.js - Scroll detection → Rule-based scoring: supplies scroll behavior
README.md - Active-time tracking → Rule-based scoring: supplies session duration
README.md - Rule-based scoring → Blur and check-in: triggers check-in
README.md - Blur and check-in → Web page: blurs page
content.js - Blur and check-in → User: asks for check-in
README.md - User → Blur and check-in: chooses response
content.js - User → Popup dashboard: opens dashboard
README.md - Popup dashboard → Dashboard controller: loads controls
popup.js - Dashboard controller → Background worker: requests global stats
popup.js - Dashboard controller → Background worker: updates settings
popup.js - Dashboard controller → Background worker: resets statistics
popup.js - Dashboard controller → Scroll detection: requests live metrics
popup.js - Dashboard controller → Blur and check-in: requests test prompt
popup.js - Background worker → Local statistics and settings: reads and writes
background.js - Background worker → Extension badge: sets alert badge
background.js - Active-time tracking → Background worker: sends focus heartbeat
content.js