mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-11-30 09:57:52 +01:00
fix: sendVote infinitely looping (#1155)
This commit is contained in:
1 file changed
+6
-3
@@ -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) => {
|
api.storage.sync.get(null, async (storageResult) => {
|
||||||
if (!storageResult.userId || !storageResult.registrationConfirmed) {
|
if (!storageResult.userId || !storageResult.registrationConfirmed) {
|
||||||
await register();
|
await register();
|
||||||
@@ -113,11 +113,14 @@ async function sendVote(videoId, vote) {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (voteResponse.status == 401) {
|
if (voteResponse.status == 401 && depth > 0) {
|
||||||
await register();
|
await register();
|
||||||
await sendVote(videoId, vote);
|
await sendVote(videoId, vote, depth-1);
|
||||||
|
return;
|
||||||
|
} else if (voteResponse.status == 401) { // We have already tried registering
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const voteResponseJson = await voteResponse.json();
|
const voteResponseJson = await voteResponse.json();
|
||||||
const solvedPuzzle = await solvePuzzle(voteResponseJson);
|
const solvedPuzzle = await solvePuzzle(voteResponseJson);
|
||||||
if (!solvedPuzzle.solution) {
|
if (!solvedPuzzle.solution) {
|
||||||
|
|||||||
Reference in new issue
Block a user