From 2cefb9822b6cecf63621fb91fc44de6d0c38df86 Mon Sep 17 00:00:00 2001 From: Ajay Date: Sat, 18 Jan 2025 03:13:40 -0500 Subject: [PATCH] Make copy button in popup use full segment ID --- src/popup.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/popup.ts b/src/popup.ts index b20723a2..0776fd24 100644 --- a/src/popup.ts +++ b/src/popup.ts @@ -681,9 +681,22 @@ async function runThePopup(messageListener?: MessageListener): Promise { uuidButton.className = "voteButton"; uuidButton.src = chrome.runtime.getURL("icons/clipboard.svg"); uuidButton.title = chrome.i18n.getMessage("copySegmentID"); - uuidButton.addEventListener("click", () => { - copyToClipboard(UUID); + uuidButton.addEventListener("click", async () => { const stopAnimation = AnimationUtils.applyLoadingAnimation(uuidButton, 0.3); + + if (UUID.length > 60) { + copyToClipboard(UUID); + } else { + const segmentIDData = await asyncRequestToServer("GET", "/api/segmentID", { + UUID: UUID, + videoID: currentVideoID + }); + + if (segmentIDData.ok && segmentIDData.responseText) { + copyToClipboard(segmentIDData.responseText); + } + } + stopAnimation(); });