mirror of
https://github.com/Shik3i/KoalaSync.git
synced 2026-07-26 12:08:15 +00:00
076157fef1
Disney+'s <video> is blob-relative (unusable as an absolute clock) and its scrubber aria-value freezes during playback, so DOM scraping lagged and the +/-10s button seek could neither reach far targets nor land precisely. The real player hangs off the <disney-web-player> custom element as `.mediaPlayer`, exposing seek(ms) and timeline.info (playhead/duration ms). Since the isolated content world can't read that page object, route it through the existing MAIN-world page-API bridge (as Netflix already does): - page-api-seek-overrides.js: register a 'disney' provider. - background.js installPageApiSeekBridge: seek Disney via mediaPlayer.seek(), and post the exact playhead/duration (seconds) to the content world every 250ms. Both are gated on provider === 'disney'; Netflix path unchanged. - content.js: cache the pushed playhead, prefer it in getDisneyPlusTimeline (DOM scraping stays as fallback), and check the page-API seek first in seekVideo. Outcome is identical for Netflix and generic sites. Verified live on Disney+: reported time matches the player exactly and seek lands within ~1s of the target. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
(function(root) {
|
|
const PAGE_API_SEEK_FIXES = [
|
|
{
|
|
name: 'netflix-page-api-seek',
|
|
urls: ['netflix.com'],
|
|
provider: 'netflix'
|
|
},
|
|
{
|
|
name: 'disney-page-api-seek',
|
|
urls: ['disneyplus.com'],
|
|
provider: 'disney'
|
|
}
|
|
];
|
|
|
|
function normalizeHost(input) {
|
|
try {
|
|
return new URL(input).hostname.toLowerCase();
|
|
} catch (_e) {
|
|
return String(input || '').toLowerCase();
|
|
}
|
|
}
|
|
|
|
function matchesDomain(host, domain) {
|
|
const normalizedDomain = normalizeHost(domain);
|
|
return normalizedDomain && (host === normalizedDomain || host.endsWith(`.${normalizedDomain}`));
|
|
}
|
|
|
|
root.KOALA_PAGE_API_SEEK_FIXES = PAGE_API_SEEK_FIXES;
|
|
root.KOALA_PAGE_API_SEEK_PROVIDERS = PAGE_API_SEEK_FIXES;
|
|
root.koalaFindPageApiSeekProvider = (input) => {
|
|
const host = normalizeHost(input);
|
|
return PAGE_API_SEEK_FIXES.find(entry =>
|
|
Array.isArray(entry.urls) && entry.urls.some(url => matchesDomain(host, url))
|
|
) || null;
|
|
};
|
|
})(globalThis);
|