|
@@ -1,5 +1,5 @@
|
|
import { clamp, interceptWindowEvent, pauseFor } from "@sv443-network/userutils";
|
|
import { clamp, interceptWindowEvent, pauseFor } from "@sv443-network/userutils";
|
|
-import { domLoaded, error, getDomain, getVideoTime, getWatchId, info, log, getVideoSelector, waitVideoElementReady, clearNode, currentMediaType } from "../utils/index.js";
|
|
|
|
|
|
+import { domLoaded, error, getDomain, getVideoTime, getWatchId, info, log, waitVideoElementReady, clearNode, currentMediaType, dbg, getVideoElement } from "../utils/index.js";
|
|
import { getFeature } from "../config.js";
|
|
import { getFeature } from "../config.js";
|
|
import { addSelectorListener } from "../observers.js";
|
|
import { addSelectorListener } from "../observers.js";
|
|
import { initialParams } from "../constants.js";
|
|
import { initialParams } from "../constants.js";
|
|
@@ -134,6 +134,7 @@ async function restVidRestoreTime() {
|
|
else {
|
|
else {
|
|
let vidElem: HTMLVideoElement;
|
|
let vidElem: HTMLVideoElement;
|
|
const doRestoreTime = async () => {
|
|
const doRestoreTime = async () => {
|
|
|
|
+ dbg("Restoring time to", entry.songTime);
|
|
if(!vidElem)
|
|
if(!vidElem)
|
|
vidElem = await waitVideoElementReady();
|
|
vidElem = await waitVideoElementReady();
|
|
const vidRestoreTime = entry.songTime - (getFeature("rememberSongTimeReduction") ?? 0);
|
|
const vidRestoreTime = entry.songTime - (getFeature("rememberSongTimeReduction") ?? 0);
|
|
@@ -163,11 +164,13 @@ async function restVidStartUpdateLoop() {
|
|
return;
|
|
return;
|
|
lastSongTime = songTime;
|
|
lastSongTime = songTime;
|
|
|
|
|
|
|
|
+ dbg("># looped, different songTime:", songTime);
|
|
|
|
+
|
|
const watchID = getWatchId();
|
|
const watchID = getWatchId();
|
|
if(!watchID)
|
|
if(!watchID)
|
|
return;
|
|
return;
|
|
|
|
|
|
- const paused = document.querySelector<HTMLVideoElement>(getVideoSelector())?.paused ?? false;
|
|
|
|
|
|
+ const paused = getVideoElement()?.paused ?? false;
|
|
|
|
|
|
// don't immediately update to reduce race conditions and only update if the video is playing
|
|
// don't immediately update to reduce race conditions and only update if the video is playing
|
|
// also it just sounds better if the song starts at the beginning if only a couple seconds have passed
|
|
// also it just sounds better if the song starts at the beginning if only a couple seconds have passed
|
|
@@ -180,7 +183,7 @@ async function restVidStartUpdateLoop() {
|
|
await restVidSetEntry(entry);
|
|
await restVidSetEntry(entry);
|
|
}
|
|
}
|
|
// if the song is rewound to the beginning, update the entry accordingly
|
|
// if the song is rewound to the beginning, update the entry accordingly
|
|
- else {
|
|
|
|
|
|
+ else if(!paused) {
|
|
const entry = remVidsCache.find(entry => entry.watchID === watchID);
|
|
const entry = remVidsCache.find(entry => entry.watchID === watchID);
|
|
if(entry && songTime <= entry.songTime)
|
|
if(entry && songTime <= entry.songTime)
|
|
await restVidSetEntry({ ...entry, songTime, updateTimestamp: Date.now() });
|
|
await restVidSetEntry({ ...entry, songTime, updateTimestamp: Date.now() });
|
|
@@ -210,6 +213,7 @@ async function restVidSetEntry(data: RemVidObj) {
|
|
|
|
|
|
/** Deletes an entry */
|
|
/** Deletes an entry */
|
|
async function restVidDeleteEntry(watchID: string) {
|
|
async function restVidDeleteEntry(watchID: string) {
|
|
|
|
+ dbg("Deleting entry with watchID", watchID);
|
|
remVidsCache = [...remVidsCache.filter(entry => entry.watchID !== watchID)];
|
|
remVidsCache = [...remVidsCache.filter(entry => entry.watchID !== watchID)];
|
|
await GM.setValue("bytm-rem-songs", JSON.stringify(remVidsCache));
|
|
await GM.setValue("bytm-rem-songs", JSON.stringify(remVidsCache));
|
|
}
|
|
}
|