Fix DEV_SIMULATE_REMOTE_SEEK targetTime routing in background.js and add build identifier

This commit is contained in:
Timo
2026-07-02 12:57:58 +02:00
parent 01762b0c2f
commit beda924b65
3 changed files with 18 additions and 6 deletions
+8 -6
View File
@@ -1615,7 +1615,7 @@ async function getReadyTabVideoState(tabId) {
return state;
}
async function simulateRemoteSeek(delta) {
async function simulateRemoteSeek(delta, explicitTargetTime = null) {
if (!currentTabId) return { status: 'no_tab' };
const tabId = parseInt(currentTabId);
if (isNaN(tabId)) return { status: 'no_tab' };
@@ -1624,7 +1624,7 @@ async function simulateRemoteSeek(delta) {
if (!state || state.error) return { status: 'error', message: state?.error || 'No video state' };
if (!state.found || !Number.isFinite(state.currentTime)) return { status: 'no_video' };
let targetTime = Math.max(0, state.currentTime + delta);
let targetTime = explicitTargetTime !== null ? explicitTargetTime : Math.max(0, state.currentTime + (delta || 0));
if (Number.isFinite(state.duration) && state.duration > 0) {
targetTime = Math.min(targetTime, Math.max(0, state.duration - 0.1));
}
@@ -2143,12 +2143,14 @@ async function handleAsyncMessage(message, sender, sendResponse) {
sendResponse({ status: 'forbidden' });
return;
}
const delta = Number(message.delta);
if (!Number.isFinite(delta)) {
sendResponse({ status: 'invalid_delta' });
const delta = message.delta !== null && message.delta !== undefined ? Number(message.delta) : null;
const targetTime = message.targetTime !== null && message.targetTime !== undefined ? Number(message.targetTime) : null;
if (delta === null && targetTime === null) {
sendResponse({ status: 'invalid_params' });
return;
}
simulateRemoteSeek(delta).then(sendResponse).catch(err => {
simulateRemoteSeek(delta, targetTime).then(sendResponse).catch(err => {
addLog(`Remote seek simulation failed: ${err.message}`, 'warn');
sendResponse({ status: 'error', message: err.message });
});
+4
View File
@@ -699,6 +699,10 @@
<button id="remoteSeekBack" class="secondary" style="flex:1; font-size:12px;">-30s</button>
<button id="remoteSeekForward" class="secondary" style="flex:1; font-size:12px;">+30s</button>
</div>
<button id="remoteSeekFiveMin" class="secondary" style="width:100%; font-size:12px; margin-bottom:15px;">Seek 5:00</button>
<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>
</div>
<script src="popup.js" type="module"></script>
+6
View File
@@ -140,6 +140,12 @@ function copyExtensionFiles(targetDir, browserName) {
fs.writeFileSync(destPath, content);
console.log(`✓ Injected uninstall URL constants for ${browserName} into background.js`);
} else if (item === 'popup.html') {
let content = fs.readFileSync(srcPath, 'utf8');
const timestamp = new Date().toISOString().replace('T', ' ').substring(0, 19) + ' UTC';
content = content.replace(/__BUILD_TIMESTAMP__/g, timestamp);
fs.writeFileSync(destPath, content);
console.log(`✓ Injected build timestamp into popup.html: ${timestamp}`);
} else {
fs.copyFileSync(srcPath, destPath);
}