feat: add audio tracking for background tabs#609
Merged
sheepzh merged 2 commits intosheepzh:mainfrom Nov 10, 2025
mrfragger:feature/audio-tracking
Merged
feat: add audio tracking for background tabs#609sheepzh merged 2 commits intosheepzh:mainfrom mrfragger:feature/audio-tracking
sheepzh merged 2 commits intosheepzh:mainfrom
mrfragger:feature/audio-tracking
Conversation
- Add AudioTabListener to track audio playback in inactive tabs - Track tab state changes during playback to record only background time - Prevent double counting by skipping active tab segments - Add onTabRemoved wrapper to chrome tab API When users play media (e.g., YouTube) and switch to another tab, the audio continues playing in the background. This feature tracks that background playback time separately from active tab time tracked by content scripts.
Owner
|
@mrfragger hi, thanks for your PR. there may be not accurate on Chrome and Edge. since they all don't promise the service worker always alive, which causes all audio states loss if background script is unloaded randomly. so I think it's better to store the audio state of each tab in the contentscript and report them with payload of tracking event, while I don't find any API to do that. but we can still monitor tabs by extension API, and send them to the tab's contentscript |
- Store audio playback state in chrome.storage.local every 5 seconds - Restore state on service worker restart - Ensures tracking survives service worker termination in Manifest V3 browsers - Minimal overhead: only persists when tabs are actively playing audio Tested on Chrome/Iron with manual service worker termination.
sheepzh
approved these changes
Nov 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds audio tracking for background tabs using the browser's
tab.audibleAPI to track media playback when tabs are inactive. Currently, the extension only tracks time when users actively interact with a tab (via content scripts). When users play media (like YouTube videos) and switch to another tab, that background playback time is not tracked. Addresses #415tab.audibleproperty changes viaonTabUpdatedlistenerTested on Firefox/LibreWolf with YouTube videos: