fix(extension): report a video the monitor finds when it installs

A monitor took the current DOM as its baseline on install, so a video that was
already present counted as "not a change" and was never announced. The discovery
poll added in the previous commit reinstalled monitors every 2s, which meant a
video appearing between two reinstalls was silently swallowed — the reported
debug log had no [Content] lines at all, which is the signature of exactly this.

Monitors now announce a video that is already there when they install, which
also makes the rebuilt-frame case work by construction rather than by timing.
The reinstall interval is raised to 5s now that each install is informative.

Also adds docs/frame-targeting-handoff.md: why v3.1.2 worked immediately with
webNavigation, why reconstructing that single call from sweeps, a learned
registry, per-frame monitors and a poll keeps producing timing windows, and the
proposed structural replacement (chrome.scripting.registerContentScripts with
allFrames, no new permission) together with the project invariant it conflicts
with — which is the owner's decision, not a code change to make unasked.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Timo
2026-08-18 20:54:53 +02:00
parent 226453fd45
commit bf0dfb82c6
3 changed files with 139 additions and 1 deletions
+3 -1
View File
@@ -150,7 +150,9 @@ function forgetFrameIds(tabId) {
// there later. Reinstalling monitors is cheap, bounded and idempotent, unlike a
// full reactivation — but it still needs a floor so page churn cannot turn it
// into a storm.
const MONITOR_REFRESH_INTERVAL_MS = 1500;
// Reinstalling is now informative rather than amnesic, but it is still work in
// every frame; keep it well clear of the discovery poll's own cadence.
const MONITOR_REFRESH_INTERVAL_MS = 5000;
const lastMonitorRefreshByTab = new Map();
const pendingMonitorRefreshByTab = new Map();
+5
View File
@@ -191,6 +191,11 @@
});
hookFrames();
lastCandidateSignature = candidateSignature();
// A monitor installed after the player already exists would otherwise take
// that player as its baseline and never mention it. Frames get a monitor
// late all the time — a rebuilt document, a reinstall — so announce an
// already-present video once instead of staying silent about it.
if (document.querySelector('video')) schedule('monitor_installed', { force: true });
window.addEventListener('pagehide', handlePageHide);
window.addEventListener('pageshow', handlePageShow);
window.addEventListener('resize', handleResize, { passive: true });