mirror of
https://github.com/Shik3i/KoalaSync.git
synced 2026-08-22 08:56:36 +00:00
fix(extension): support Google Drive video frames
This commit is contained in:
+70
-25
@@ -6,13 +6,15 @@
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
(function() {
|
||||
|
||||
|
||||
(function() {
|
||||
|
||||
// Injection Guard: Check if already injected AND context is valid
|
||||
|
||||
try {
|
||||
try {
|
||||
|
||||
if (window.koalaSyncInjected && chrome.runtime.id) {
|
||||
window.koalaSyncTargetActive = true;
|
||||
return;
|
||||
}
|
||||
@@ -86,9 +88,34 @@
|
||||
if (_suppressTimers[state]) {
|
||||
|
||||
clearTimeout(_suppressTimers[state]);
|
||||
|
||||
if (_suppressTimers[state]) {
|
||||
|
||||
|
||||
delete _suppressTimers[state];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// --- Seek Relay Filtering ---
|
||||
|
||||
// Minimum seek delta (seconds) to report. Prevents HLS/DASH buffering micro-seeks
|
||||
|
||||
// from being relayed to peers as user-initiated seeks.
|
||||
|
||||
const MIN_SEEK_DELTA = 2.0;
|
||||
|
||||
let lastReportedSeekTime = null; // last currentTime we relayed as a SEEK
|
||||
|
||||
let seekDebounceTimer = null; // debounce timer for rapid seek events
|
||||
|
||||
let expectedSeekTime = null; // strictly track programmatic seeks
|
||||
|
||||
|
||||
|
||||
const PAGE_API_SEEK_BRIDGE = 1;
|
||||
// Accurate Disney+ playhead pushed by the MAIN-world page-API bridge
|
||||
// (background.js installPageApiSeekBridge). The isolated content world
|
||||
// can't read the page's media player directly.
|
||||
let disneyPageApiTime = null;
|
||||
if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') {
|
||||
@@ -851,11 +878,17 @@
|
||||
document.addEventListener('DOMContentLoaded', retry, { once: true });
|
||||
|
||||
} else {
|
||||
|
||||
document.addEventListener('DOMContentLoaded', retry, { once: true });
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
setTimeout(retry, 50);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
const host = hcmEl('div', 'all:initial');
|
||||
|
||||
const root = host.attachShadow({ mode: 'open' });
|
||||
@@ -864,9 +897,11 @@
|
||||
|
||||
b.append(hcmEl('span', null, '● ' + hcmStrings.badge), hcmEl('span', 'text-decoration:underline', hcmStrings.resync));
|
||||
|
||||
}
|
||||
|
||||
const host = hcmEl('div', 'all:initial');
|
||||
b.addEventListener('click', hcmExitDesync);
|
||||
|
||||
root.appendChild(b);
|
||||
|
||||
document.body.appendChild(host);
|
||||
|
||||
hcmBadgeHost = host;
|
||||
|
||||
@@ -951,8 +986,14 @@
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (candidates.length === 0) return null;
|
||||
|
||||
|
||||
|
||||
// Multiple videos found → pick the best one
|
||||
|
||||
if (candidates.length === 1) return candidates[0];
|
||||
|
||||
|
||||
|
||||
@@ -1136,9 +1177,10 @@
|
||||
|
||||
|
||||
|
||||
const ctx = initAudioContext();
|
||||
|
||||
if (!ctx) return null;
|
||||
src.connect(dryGain);
|
||||
|
||||
dryGain.connect(ctx.destination);
|
||||
|
||||
src.connect(compressor);
|
||||
|
||||
compressor.connect(compGain);
|
||||
@@ -1271,8 +1313,9 @@
|
||||
|
||||
}
|
||||
|
||||
|
||||
chain.compressor.release.value = params.release ?? 0.300;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// --- Episode Auto-Sync: Detection ---
|
||||
|
||||
@@ -1308,8 +1351,9 @@
|
||||
const ep = title.match(/(?:Episode|Folge|Ep\.?|#)\s*(\d+)/i);
|
||||
|
||||
if (ep) return `EP${String(ep[1]).padStart(3, '0')}`;
|
||||
// Extract a canonical episode identifier from a title string.
|
||||
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1552,8 +1596,9 @@
|
||||
matches() { return isGoogleDrivePlayerFrame(); },
|
||||
playPauseButtonSelector: '.ytp-play-button'
|
||||
},
|
||||
lobbyPollTimer = null;
|
||||
|
||||
{
|
||||
name: 'twitch-player-buttons',
|
||||
urls: ['twitch.tv'],
|
||||
playPauseButtonSelector: '[data-a-target="player-play-pause-button"]'
|
||||
}
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user