From fc0b0feaa2c90a5f56a3a6de8d34ef7dbad68b7f Mon Sep 17 00:00:00 2001 From: Snow <35224538+KibbeWater@users.noreply.github.com> Date: Sun, 13 Jul 2025 13:29:34 +0200 Subject: [PATCH] fix: sendVote infinitely looping (#1155) --- Extensions/combined/ryd.background.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Extensions/combined/ryd.background.js b/Extensions/combined/ryd.background.js index fda6a4e..21feed3 100644 --- a/Extensions/combined/ryd.background.js +++ b/Extensions/combined/ryd.background.js @@ -96,7 +96,7 @@ api.runtime.onInstalled.addListener((details) => { // } // }); -async function sendVote(videoId, vote) { +async function sendVote(videoId, vote, depth = 1) { api.storage.sync.get(null, async (storageResult) => { if (!storageResult.userId || !storageResult.registrationConfirmed) { await register(); @@ -113,11 +113,14 @@ async function sendVote(videoId, vote) { }), }); - if (voteResponse.status == 401) { + if (voteResponse.status == 401 && depth > 0) { await register(); - await sendVote(videoId, vote); + await sendVote(videoId, vote, depth-1); + return; + } else if (voteResponse.status == 401) { // We have already tried registering return; } + const voteResponseJson = await voteResponse.json(); const solvedPuzzle = await solvePuzzle(voteResponseJson); if (!solvedPuzzle.solution) {