-
Notifications
You must be signed in to change notification settings - Fork 0
Architecture
Toxc edited this page May 9, 2026
·
1 revision
ReelScroller follows the standard Firefox WebExtension two-process model. A non-persistent background script manages global state and messaging; a content script injected into Instagram pages handles DOM observation and scrolling.
Toolbar Button click
│
▼
background.js
─────────────────────────────────────────
• Reads reelScrollerEnabled from storage
• Flips the value and writes it back
• Updates toolbar badge (ON / empty)
• Sends ENABLE or DISABLE message
to all open Instagram tabs
│
▼ browser.tabs.sendMessage
content_script_clean.js (runs in Instagram page)
─────────────────────────────────────────
• On ENABLE: checks if URL is /reel/ or /reels/
→ attaches MutationObserver + video 'ended' listeners
• On DISABLE: removes all listeners, observers, intervals
│
▼
DOM interaction
─────────────────────────────────────────
• Waits for video 'ended' event
• Checks nearby visible text for ad labels
• Scrolls to next Reel (or skips if sponsored)
The background script is declared as non-persistent ("persistent": false), meaning Firefox can unload it when idle to save resources.
Responsibilities:
-
Storage: Reads and writes the single boolean key
reelScrollerEnabledviabrowser.storage.local. -
Toolbar button: Listens for
browserAction.onClicked. On each click, it toggles the stored value and updates the badge text. -
Tab messaging: After toggling, iterates over all tabs matching
*://*.instagram.com/*and sends anENABLEorDISABLEmessage. -
Tab load: Listens for
tabs.onUpdated(status =complete) to send the current state to any newly loaded Instagram tab, so the content script always starts with the correct setting.
Injected at document_idle into every page on instagram.com. It does nothing until it receives a message from the background script.
Responsibilities:
-
Route check: On receiving
ENABLE, checkswindow.location.pathname. If the path is not/reel/or/reels/, the script exits early and attaches no listeners. -
Video observation: Uses a
MutationObserverto detect when video elements appear in the DOM (Instagram loads Reels dynamically). -
Scroll trigger: Attaches an
endedevent listener to the focused video. When the video ends, callsscrollToNext(). -
Ad check: Before scrolling, inspects visible text nodes near the current Reel container for sponsorship labels. If a match is found, the Reel is skipped without waiting for the
endedevent. -
Cleanup: On receiving
DISABLE, disconnects theMutationObserver, removes allendedlisteners, and clears any active intervals. The script is safe to enable and disable repeatedly — no duplicate listeners are stacked.
| Message | Direction | Meaning |
|---|---|---|
ENABLE |
background → content | Attach observers and start scrolling |
DISABLE |
background → content | Detach all observers and stop scrolling |
Only one key is ever written:
| Key | Type | Default |
|---|---|---|
reelScrollerEnabled |
boolean | true |