Skip to content

Commit

Permalink
Fixed small button text switching after shuffle had finished, and int…
Browse files Browse the repository at this point in the history
…erval checking too long
  • Loading branch information
NikkelM committed Nov 28, 2023
1 parent 488a665 commit 4f5a45c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,15 @@ async function shuffleVideos() {
let iterationsWaited = 0;

let checkInterval = setInterval(async () => {
if (!hasBeenShuffled && (shuffleButtonTextElementCopy.innerText == "100%" || (shuffleButtonTextElementCopy.innerText == "shuffle" && iterationsWaited++ >= 10))) {
if (!hasBeenShuffled && (shuffleButtonTextElementCopy.innerText == "100%" || (shuffleButtonTextElementCopy.innerText == "shuffle" && iterationsWaited++ >= 15))) {
clearInterval(checkInterval);
await delay(400);

// If we have finished the shuffle between the check and the delay, we don't want to change the text
if (hasBeenShuffled) {
return;
}

updateSmallButtonStyle(shuffleButtonTextElementCopy, false);
shuffleButtonTextElementCopy.innerText = "autorenew";
let rotation = 0;
Expand All @@ -185,9 +190,10 @@ async function shuffleVideos() {
shuffleButtonTextElementCopy.style.transform = `rotate(${rotation}deg)`;
rotation = (rotation + 5) % 360;
}, 25);
} else if (hasBeenShuffled) {
clearInterval(checkInterval);
}
await delay(100);
}, 100);
}, 150);
}

await chooseRandomVideo(channelId, false, shuffleButtonTextElement);
Expand Down

0 comments on commit 4f5a45c

Please sign in to comment.