Skip to content

Instantly share code, notes, and snippets.

@Heinrich-XIAO
Created November 4, 2024 00:01
Show Gist options
  • Save Heinrich-XIAO/2fc5bdf0059193e3d468d93e43ba13e8 to your computer and use it in GitHub Desktop.
Save Heinrich-XIAO/2fc5bdf0059193e3d468d93e43ba13e8 to your computer and use it in GitHub Desktop.
const diff = require('deep-diff').diff;
async function main(groupId) {
let res = await fetch("https://www.duolingo.com/2017-06-30/sessions", {
"credentials": "include",
"headers": {
"Content-Type": "application/json; charset=UTF-8",
"Authorization": "Bearer Put your bearer ode here"
},
body: JSON.stringify({
challengeTypes: [
"assist", "characterIntro", "characterMatch", "characterPuzzle", "characterSelect",
"characterTrace", "characterWrite", "completeReverseTranslation", "definition", "dialogue",
"extendedMatch", "extendedListenMatch", "form", "freeResponse", "gapFill", "judge",
"listen", "listenComplete", "listenMatch", "match", "name", "listenComprehension",
"listenIsolation", "listenSpeak", "listenTap", "orderTapComplete", "partialListen",
"partialReverseTranslate", "patternTapComplete", "radioBinary", "radioImageSelect",
"radioListenMatch", "radioListenRecognize", "radioSelect", "readComprehension",
"reverseAssist", "sameDifferent", "select", "selectPronunciation", "selectTranscription",
"svgPuzzle", "syllableTap", "syllableListenTap", "speak", "tapCloze", "tapClozeTable",
"tapComplete", "tapCompleteTable", "tapDescribe", "translate", "transliterate",
"transliterationAssist", "typeCloze", "typeClozeTable", "typeComplete",
"typeCompleteTable", "writeComprehension"
],
fromLanguage: "en",
isFinalLevel: false,
isV2: true,
juicy: true,
learningLanguage: "zh",
shakeToReportEnabled: true,
smartTipsVersion: 2,
alphabetId: "hanzi",
alphabetSessionId: `hanzi|groupId:${groupId}`,
groupId: groupId,
alphabetsPathProgressKey: "ed9ca1e0af0b81cb07aa679727c362a5-4",
type: "ALPHABET_LESSON"
}),
"method": "POST",
"mode": "cors"
})
const questions = await res.json();
const timeItTook = 100;
const answer = structuredClone(questions);
answer.heartsLeft = 0;
answer.startTime = Math.floor(Date.now() / 1000)-10;
answer.endTime = Math.floor(Date.now() / 1000)+timeItTook;
answer.enableBonusPoints = false;
answer.failed = false;
console.log(questions);
answer.maxInLessonStreak = questions.challenges.length;
answer.shouldLearnThings = true;
for (let i = 0; i < answer.challenges.length; i++) {
answer.challenges[i].correct = true;
// .timeTaken should be shared between all challenges and be randomized and should always sum to timeItTook
answer.challenges[i].timeTaken = timeItTook/answer.challenges.length;
}
console.log("Starting Timeout of " + timeItTook + " milliseconds");
await new Promise(resolve => setTimeout(resolve, timeItTook));
console.log("Timeout Complete");
res = await fetch("https://www-prod.duolingo.com/2017-06-30/alphabets/sessions/zh/en/65131970-d50e-4d5f-bd59-3e083c4b9f18", {
"credentials": "include",
"headers": {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0",
"Accept": "application/json; charset=UTF-8",
"Accept-Language": "en-US,en;q=0.5",
"Content-Type": "application/json; charset=UTF-8",
"X-Amzn-Trace-Id": "User=1398442445",
"X-Requested-With": "XMLHttpRequest",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-site",
"Authorization": "Bearer Put your bearer code here",
"Priority": "u=0",
"Pragma": "no-cache",
"Cache-Control": "no-cache"
},
"referrer": "https://www.duolingo.com/",
"body": JSON.stringify(answer),
"method": "PUT",
"mode": "cors"
});
console.log(await res.json());
}
async function runMainFourHundredTimes(groupId) {
const times = 200;
for (let i = 0; i < times; i++) {
await main(groupId);
if ((i+1) % 20 == 0)
await new Promise(resolve => setTimeout(resolve, 5000));
}
}
async function runAllGroups() {
for (let i = 0; i < 67; i++) {
await runMainFourHundredTimes(i);
}
}
runAllGroups();
@Heinrich-XIAO
Copy link
Author

Remember to put your bearer code in, otherwise this obvously won't work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment