mirror of
https://github.com/Shik3i/KoalaSync.git
synced 2026-08-08 10:23:19 +00:00
Remove temporary Media Session interceptor and Video Event Log diagnostics
Clean up the exploratory Disney+ diagnostics now that the Shadow DOM timeline/seek integration is in place: - Remove Proposal 1 (Media Session interceptor): the background.js interceptor injection and the content.js message listener capturing __koalaMediaSessionCapture, plus the now-unused mediaSessionPosition reporting in content.js and popup.js. - Remove Proposal 3 (Video Event Log): videoEventsLog, logVideoEvent(), the per-video event logging listeners, and the popup.html/popup.js UI. - Keep Proposal 2 (DOM timestamp scraper) for ongoing diagnostics. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1654,42 +1654,6 @@ async function devRemoteToolsAllowed() {
|
||||
return data.username === 'KoalaDev';
|
||||
}
|
||||
|
||||
const mediaSessionInterceptorHosts = [
|
||||
'disneyplus.com'
|
||||
];
|
||||
|
||||
function shouldInstallMediaSessionInterceptor(url) {
|
||||
try {
|
||||
const host = new URL(url).hostname.toLowerCase();
|
||||
return mediaSessionInterceptorHosts.some(h => host === h || host.endsWith('.' + h));
|
||||
} catch (_e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function installMediaSessionInterceptor() {
|
||||
if (window.__koalaMediaSessionInterceptorInstalled) return;
|
||||
window.__koalaMediaSessionInterceptorInstalled = true;
|
||||
if (!navigator.mediaSession || typeof navigator.mediaSession.setPositionState !== 'function') return;
|
||||
|
||||
const originalSet = navigator.mediaSession.setPositionState;
|
||||
navigator.mediaSession.setPositionState = function(state) {
|
||||
try {
|
||||
window.postMessage({
|
||||
__koalaMediaSessionCapture: 1,
|
||||
state: {
|
||||
duration: state?.duration,
|
||||
playbackRate: state?.playbackRate,
|
||||
position: state?.position
|
||||
}
|
||||
}, '*');
|
||||
} catch (_e) {
|
||||
// Suppress errors to not interfere with player
|
||||
}
|
||||
return originalSet.apply(navigator.mediaSession, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
function shouldUsePageApiSeek(url) {
|
||||
return typeof globalThis.koalaFindPageApiSeekProvider === 'function' &&
|
||||
!!globalThis.koalaFindPageApiSeekProvider(url);
|
||||
@@ -1733,12 +1697,10 @@ function setPageApiSeekEnabled(enabled) {
|
||||
async function injectContentScript(tabId) {
|
||||
let needsPageApiSeek = false;
|
||||
let pageApiSeekReady = false;
|
||||
let isMediaSessionCapable = false;
|
||||
try {
|
||||
const tab = await chrome.tabs.get(tabId);
|
||||
const url = tab?.url || '';
|
||||
needsPageApiSeek = shouldUsePageApiSeek(url);
|
||||
isMediaSessionCapable = shouldInstallMediaSessionInterceptor(url);
|
||||
} catch (_e) {
|
||||
// Fall through to the generic content script injection.
|
||||
}
|
||||
@@ -1761,18 +1723,6 @@ async function injectContentScript(tabId) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isMediaSessionCapable) {
|
||||
try {
|
||||
await chrome.scripting.executeScript({
|
||||
target: { tabId },
|
||||
world: 'MAIN',
|
||||
func: installMediaSessionInterceptor
|
||||
});
|
||||
} catch (err) {
|
||||
addLog(`Media Session interceptor injection failed: ${err.message}`, 'warn');
|
||||
}
|
||||
}
|
||||
|
||||
await chrome.scripting.executeScript({
|
||||
target: { tabId },
|
||||
files: ['page-api-seek-overrides.js']
|
||||
|
||||
@@ -62,7 +62,6 @@
|
||||
|
||||
// Suppresses native event reporting after a programmatic action.
|
||||
|
||||
// Each entry is a per-type timer (key = 'playing'|'paused'|'seek').
|
||||
// Each entry is a per-type timer (key = 'playing'|'paused'|'seek').
|
||||
|
||||
// While a timer exists, matching native events are consumed and not relayed.
|
||||
@@ -1445,9 +1444,7 @@
|
||||
|
||||
function applyAudioSettings(videoEl, settings) {
|
||||
|
||||
const mergedSettings = mergeAudioSettings(settings);
|
||||
const mergedSettings = mergeAudioSettings(settings);
|
||||
if (!mergedSettings.enabled || !mergedSettings.compressor?.enabled) {
|
||||
|
||||
if (!mergedSettings.enabled || !mergedSettings.compressor?.enabled) {
|
||||
|
||||
@@ -1459,9 +1456,7 @@
|
||||
|
||||
|
||||
|
||||
if (!chain) return;
|
||||
const chain = setupAudioChain(videoEl);
|
||||
|
||||
|
||||
if (!chain) return;
|
||||
|
||||
@@ -1752,21 +1747,6 @@
|
||||
checkAndReportLobbyReady(expectedTitle);
|
||||
|
||||
}, 2000);
|
||||
|
||||
|
||||
|
||||
function stopLobbyPoll() {
|
||||
|
||||
_pendingLobbyTitle = null;
|
||||
|
||||
if (lobbyPollTimer) {
|
||||
|
||||
clearInterval(lobbyPollTimer);
|
||||
|
||||
lobbyPollTimer = null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1782,14 +1762,6 @@
|
||||
|
||||
clearInterval(lobbyPollTimer);
|
||||
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
function getActivePlayerActionFix() {
|
||||
return getPlayerActionFixes().find(fix => matchesPlayerUrls(fix.urls)) || null;
|
||||
}
|
||||
|
||||
lobbyPollTimer = null;
|
||||
|
||||
}
|
||||
@@ -1947,14 +1919,6 @@
|
||||
}
|
||||
|
||||
|
||||
if (video) applyAudioSettings(video, _audioSettings);
|
||||
|
||||
sendResponse({ ok: true });
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Listen for commands from background.js
|
||||
|
||||
|
||||
@@ -706,12 +706,6 @@
|
||||
No timestamps scraped.
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-top: 15px; margin-bottom:15px;">
|
||||
<label style="font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:0.5px;">Video Event Log</label>
|
||||
<div class="info-card" id="devtoolsVideoEventLogList" style="font-size:10px; max-height:150px; overflow-y:auto; font-family:monospace; line-height:1.2; padding:6px; background:rgba(0,0,0,0.2); white-space:pre-wrap; border: 1px solid #334155;">
|
||||
No events logged.
|
||||
</div>
|
||||
</div>
|
||||
<div style="font-size:10px; color:var(--text-muted); text-align:center; margin-top:10px; opacity:0.7;">
|
||||
Build: <span id="buildIdentifier">__BUILD_TIMESTAMP__</span>
|
||||
</div>
|
||||
|
||||
+2
-12
@@ -2283,10 +2283,6 @@ function refreshDebugInfo() {
|
||||
if (state.nativeCurrentTime != null || state.nativeDuration != null) {
|
||||
addField('Native Time', `${state.nativeCurrentTime ?? '?'}s / ${state.nativeDuration ?? '?'}s`);
|
||||
}
|
||||
if (state.mediaSessionPosition) {
|
||||
const pos = state.mediaSessionPosition;
|
||||
addField('MediaSession Captured', `${pos.position ?? '?'}s / ${pos.duration ?? '?'}s (@ ${pos.playbackRate ?? 1}x)`, '#a855f7');
|
||||
}
|
||||
if (state.siteQuirk) {
|
||||
const quirk = state.siteQuirk;
|
||||
const label = quirk.name || quirk.key || 'Site';
|
||||
@@ -2297,17 +2293,11 @@ function refreshDebugInfo() {
|
||||
if (buttons) addField(`${label} Buttons`, buttons);
|
||||
}
|
||||
const domScraperEl = document.getElementById('devtoolsDomScraperList');
|
||||
const eventLogEl = document.getElementById('devtoolsVideoEventLogList');
|
||||
if (domScraperEl && state.scrapedTimestamps) {
|
||||
domScraperEl.textContent = state.scrapedTimestamps.length > 0
|
||||
? state.scrapedTimestamps.join('\n')
|
||||
domScraperEl.textContent = state.scrapedTimestamps.length > 0
|
||||
? state.scrapedTimestamps.join('\n')
|
||||
: 'No timestamps scraped.';
|
||||
}
|
||||
if (eventLogEl && state.videoEventsLog) {
|
||||
eventLogEl.textContent = state.videoEventsLog.length > 0
|
||||
? state.videoEventsLog.join('\n')
|
||||
: 'No events logged.';
|
||||
}
|
||||
|
||||
addSection('Properties');
|
||||
addField('Seeking', String(state.seeking));
|
||||
|
||||
Reference in New Issue
Block a user