diff --git a/index.html b/index.html index 8777e56..ddee349 100644 --- a/index.html +++ b/index.html @@ -84,6 +84,7 @@ Scale (%): Fade (ms): + Debug: use history for Song requests: Debug BSR ID: e.g. 43239 diff --git a/index.js b/index.js index 88ac278..555c477 100644 --- a/index.js +++ b/index.js @@ -12,7 +12,8 @@ var OVERLAY_SETTINGS_INITIAL = { bottom: true, scale: 1, fade: 300, - debugSongId: "" + debugSongId: "", + debugUseHistoryForRequests: false }; // src/client/beatsaver.ts @@ -649,8 +650,11 @@ async function refreshMapFriendScores() { window.onhashchange = () => { loadSettings(); void refreshConfiguredPlayerAvatar(); + void loadRequestQueue(); const debugEl = document.getElementById("debugSongIdInput"); if (debugEl) debugEl.value = settings.debugSongId; + const debugHistoryEl = document.getElementById("debugUseHistoryForRequestsInput"); + if (debugHistoryEl) debugHistoryEl.checked = settings.debugUseHistoryForRequests; if (settings.debugSongId.trim()) void applyDebugSong(); else { mapInfoRequestId += 1; @@ -745,7 +749,8 @@ async function loadRequestQueue() { const data = await loadChatRequestJson(); requestEmptyEl.textContent = "No pending requests"; requestOverlayEl.classList.remove("request-load-failed"); - const items = (data.queue ?? []).slice(0, MAX_REQUESTS); + const source = settings.debugUseHistoryForRequests ? data.history ?? [] : data.queue ?? []; + const items = source.slice(0, MAX_REQUESTS); renderRequestList(items); } catch { requestEmptyEl.textContent = "Request queue unavailable"; @@ -777,7 +782,8 @@ async function bootstrap() { "time", "score", "friends", - "bsr" + "bsr", + "debugUseHistoryForRequests" ]) { const input = must(`${key}Input`); input.checked = settings[key]; @@ -785,6 +791,7 @@ async function bootstrap() { settings[key] = input.checked; saveSettings(); if (key === "friends") void refreshMapFriendScores(); + if (key === "debugUseHistoryForRequests") void loadRequestQueue(); }; } const friendModeInput = must("friendModeInput"); diff --git a/samples/Database.json b/samples/Database.json new file mode 100644 index 0000000..3625440 --- /dev/null +++ b/samples/Database.json @@ -0,0 +1,283 @@ +{ + "queue": [], + "history": [ + { + "key": "4cc2b", + "rqt": 1775779098, + "rqn": "timmyboi101", + "npr": "", + "msg": "" + }, + { + "key": "41d0a", + "rqt": 1775088648, + "rqn": "raverbeandk", + "npr": "", + "msg": "" + }, + { + "key": "4eabc", + "rqt": 1773187529, + "rqn": "whizlol_", + "npr": "", + "msg": "" + }, + { + "key": "4ea5c", + "rqt": 1771109245, + "rqn": "kacy121", + "npr": "", + "msg": "" + }, + { + "key": "4c351", + "rqt": 1772402287, + "rqn": "blasted246", + "npr": "", + "msg": "" + }, + { + "key": "3ecc7", + "rqt": 1772402477, + "rqn": "danielduel", + "npr": "", + "msg": "" + }, + { + "key": "4f0fd", + "rqt": 1772402471, + "rqn": "kitties", + "npr": "", + "msg": "" + }, + { + "key": "4a978", + "rqt": 1772402365, + "rqn": "blasted246", + "npr": "", + "msg": "" + }, + { + "key": "49be2", + "rqt": 1772401977, + "rqn": "danielduel", + "npr": "", + "msg": "" + }, + { + "key": "4dc91", + "rqt": 1772401902, + "rqn": "simpliftr", + "npr": "", + "msg": "" + }, + { + "key": "4e932", + "rqt": 1771109684, + "rqn": "kacy121", + "npr": "", + "msg": "" + }, + { + "key": "4edb9", + "rqt": 1772401613, + "rqn": "blasted246", + "npr": "", + "msg": "" + }, + { + "key": "42b69", + "rqt": 1772401712, + "rqn": "danielduel", + "npr": "", + "msg": "" + }, + { + "key": "3a007", + "rqt": 1772140150, + "rqn": "morlis1002", + "npr": "", + "msg": "" + }, + { + "key": "4dd71", + "rqt": 1771109448, + "rqn": "softmonkeh", + "npr": "", + "msg": "" + }, + { + "key": "4ea0b", + "rqt": 1771109231, + "rqn": "kacy121", + "npr": "", + "msg": "" + }, + { + "key": "722f", + "rqt": 1771108991, + "rqn": "kacy121", + "npr": "", + "msg": "" + }, + { + "key": "4ea9e", + "rqt": 1771108667, + "rqn": "kacy121", + "npr": "", + "msg": "" + }, + { + "key": "219cc", + "rqt": 1770861875, + "rqn": "rosa_360", + "npr": "", + "msg": "" + }, + { + "key": "ae0e", + "rqt": 1770686841, + "rqn": "unigamerplays", + "npr": "", + "msg": "" + }, + { + "key": "3bbb0", + "rqt": 1770685631, + "rqn": "unigamerplays", + "npr": "", + "msg": "" + }, + { + "key": "4d158", + "rqt": 1770686339, + "rqn": "unigamerplays", + "npr": "", + "msg": "" + }, + { + "key": "4ddac", + "rqt": 1770685592, + "rqn": "unigamerplays", + "npr": "", + "msg": "" + }, + { + "key": "e298", + "rqt": 1757616827, + "rqn": "$MenuMusic", + "npr": "🎵", + "msg": "" + }, + { + "key": "3ccc5", + "rqt": 1757215085, + "rqn": "666isbetter", + "npr": "", + "msg": "" + }, + { + "key": "3df54", + "rqt": 1757213869, + "rqn": "mirageplayzzz", + "npr": "", + "msg": "" + }, + { + "key": "3769c", + "rqt": 1757212949, + "rqn": "mirageplayzzz", + "npr": "", + "msg": "" + }, + { + "key": "345d9", + "rqt": 1757212854, + "rqn": "666isbetter", + "npr": "", + "msg": "" + }, + { + "key": "4347c", + "rqt": 1757212771, + "rqn": "mirageplayzzz", + "npr": "", + "msg": "" + }, + { + "key": "1f3bb", + "rqt": 1757212225, + "rqn": "666isbetter", + "npr": "", + "msg": "" + }, + { + "key": "26d75", + "rqt": 1757211488, + "rqn": "mirageplayzzz", + "npr": "", + "msg": "" + }, + { + "key": "44330", + "rqt": 1757211481, + "rqn": "nowahou", + "npr": "", + "msg": "" + }, + { + "key": "312c6", + "rqt": 1757211158, + "rqn": "666isbetter", + "npr": "", + "msg": "" + }, + { + "key": "2c2c6", + "rqt": 1757210672, + "rqn": "666isbetter", + "npr": "", + "msg": "" + }, + { + "key": "2e8a", + "rqt": 1757209938, + "rqn": "666isbetter", + "npr": "", + "msg": "" + }, + { + "key": "4a345", + "rqt": 1757210190, + "rqn": "abe_vs_theworld", + "npr": "", + "msg": "" + }, + { + "key": "4a329", + "rqt": 1757209712, + "rqn": "mrstacker27", + "npr": "", + "msg": "" + }, + { + "key": "4a00b", + "rqt": 1756592415, + "rqn": "mrstacker27", + "npr": "", + "msg": "" + }, + { + "key": "46a3e", + "rqt": 1748810448, + "rqn": "sabersammy0", + "npr": "", + "msg": "" + } + ], + "allowlist": [], + "blocklist": [], + "bannedusers": [], + "bannedmappers": [], + "remaps": [] +} \ No newline at end of file diff --git a/src/client/index.ts b/src/client/index.ts index dbdc82a..8b6f8fb 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -534,8 +534,11 @@ async function refreshMapFriendScores() { window.onhashchange = () => { loadSettings(); void refreshConfiguredPlayerAvatar(); + void loadRequestQueue(); const debugEl = document.getElementById("debugSongIdInput") as HTMLInputElement | null; if (debugEl) debugEl.value = settings.debugSongId; + const debugHistoryEl = document.getElementById("debugUseHistoryForRequestsInput") as HTMLInputElement | null; + if (debugHistoryEl) debugHistoryEl.checked = settings.debugUseHistoryForRequests; if (settings.debugSongId.trim()) void applyDebugSong(); else { mapInfoRequestId += 1; @@ -636,7 +639,8 @@ async function loadRequestQueue() { const data = await loadChatRequestJson(); requestEmptyEl.textContent = "No pending requests"; requestOverlayEl.classList.remove("request-load-failed"); - const items = (data.queue ?? []).slice(0, MAX_REQUESTS); + const source = settings.debugUseHistoryForRequests ? (data.history ?? []) : (data.queue ?? []); + const items = source.slice(0, MAX_REQUESTS); renderRequestList(items); } catch { requestEmptyEl.textContent = "Request queue unavailable"; @@ -665,13 +669,14 @@ async function bootstrap() { // Settings UI - for (const key of ["cover", "mapInfo", "time", "score", "friends", "bsr"] as const) { + for (const key of ["cover", "mapInfo", "time", "score", "friends", "bsr", "debugUseHistoryForRequests"] as const) { const input = must(`${key}Input`); input.checked = settings[key]; input.oninput = () => { settings[key] = input.checked; saveSettings(); if (key === "friends") void refreshMapFriendScores(); + if (key === "debugUseHistoryForRequests") void loadRequestQueue(); }; } diff --git a/src/client/types.ts b/src/client/types.ts index b545411..02e4b8b 100644 --- a/src/client/types.ts +++ b/src/client/types.ts @@ -18,6 +18,8 @@ export interface OverlaySettings { fade: number; /** Frontend-only: BeatSaver map key or 40-char hash; when set, map UI + BeatLeader use this instead of BS+ WebSocket map info. */ debugSongId: string; + /** When true, show `history` from ChatRequest/Database JSON as the request list instead of `queue`. */ + debugUseHistoryForRequests: boolean; } export const OVERLAY_SETTINGS_INITIAL: Readonly = { @@ -34,6 +36,7 @@ export const OVERLAY_SETTINGS_INITIAL: Readonly = { scale: 1, fade: 300, debugSongId: "", + debugUseHistoryForRequests: false, }; export interface HandshakeEvent { @@ -117,6 +120,7 @@ export interface ChatRequestEntry { export interface ChatRequestPayload { queue: ChatRequestEntry[]; + history?: ChatRequestEntry[]; } export interface BeatLeaderDifficulty {