Support dynamic Disney+ timeline offset/scale caching for accurate seek sync

This commit is contained in:
Timo
2026-07-02 13:30:20 +02:00
parent bea0f6925c
commit 32994aaaa5
2 changed files with 12 additions and 3 deletions
+10 -3
View File
@@ -60,6 +60,8 @@
// Suppresses native event reporting after a programmatic action.
// Each entry is a per-type timer (key = 'playing'|'paused'|'seek').
// While a timer exists, matching native events are consumed and not relayed.
@@ -265,6 +267,8 @@
if (!isDisneyPlusHost() || !Number.isFinite(delta) || Math.abs(delta) < 1 || typeof document === 'undefined') return false;
const backward = delta < 0;
const candidates = Array.from(document.querySelectorAll('button,[role="button"]'));
const backRe = /rewind|backward|back\b|zurück|zurueck|rück|rueck|retour|recul|retroced|atrás|voltar|indietro/i;
const forwardRe = /forward|ahead|skip|vorwärts|vorwaerts|vorsp|weiter|avancer|adelant|avançar|avancar|avanti/i;
const timeRe = /\b(5|10|15|30)\b|sec|sek|second/i;
const button = candidates.find(btn => {
@@ -275,13 +279,16 @@
const label = getElementLabel(btn);
return backward ? backRe.test(label) : forwardRe.test(label);
});
if (button && typeof button.click === 'function') {
const clicks = Math.max(1, Math.min(12, Math.round(Math.abs(delta) / 10)));
for (let i = 0; i < clicks; i++) {
setTimeout(() => button.click(), i * 60);
}
return true;
const clicks = Math.max(1, Math.min(12, Math.round(Math.abs(delta) / 10)));
for (let i = 0; i < clicks; i++) {
setTimeout(() => button.click(), i * 60);
}
// Fallback: Simulate ArrowLeft / ArrowRight keyboard events
const clicks = Math.max(1, Math.min(12, Math.round(Math.abs(delta) / 10)));
const eventInit = {
key: backward ? 'ArrowLeft' : 'ArrowRight',
+2
View File
@@ -92,6 +92,8 @@ function loadTimelineFns(hostname, document = makeDocument()) {
return Function('window', 'document', [
'let lastDisneyPlusTimelineCandidates = [];',
'let lastKnownDisneyPlusDuration = 0;',
'let lastKnownDisneyPlusScale = 1;',
'let lastKnownDisneyPlusStart = 0;',
extractFunction('hostMatchesUrl', source),
extractFunction('matchesPlayerUrls', source),
extractFunction('isDisneyPlusHost', source),