function getRandomInt(min, max) {
return [Link]([Link]() * (max - min + 1)) + min;
}
function generateRandomNumbers(length) {
const indices = [Link]({ length }, (_, i) => i);
for (let i = [Link] - 1; i > 0; i--) {
const j = [Link]([Link]() * (i + 1));
[indices[i], indices[j]] = [indices[j], indices[i]];
}
return indices;
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function runAutomation() {
let submitBtn;
const activitiesTitle = [Link]('[data-
qa=ActivityMapTitle]');
const courses = [Link]('[data-qa=LaunchCourseButton]');
const launchBtns = [Link]('[data-qa=LaunchButton]');
const startTime = [Link]();
const maxDuration = 60 * 60 * 1000;
const runtimes = 100;
try {
courses[getRandomInt(0, [Link] - 1)].click();
} catch (error) {
[Link]("Erreur lors du clic sur le cours :", error);
}
await sleep(500);
try {
launchBtns[getRandomInt(0, [Link] - 1)].click();
} catch (error) {
[Link]("Erreur lors du clic sur le bouton de lancement :", error);
}
while ([Link]() - startTime < maxDuration) {
for (let runtime = 0; runtime < runtimes; runtime++) {
for (let i = 0; i < [Link]; i++) {
const activity = activitiesTitle[i];
if (!activity) {
[Link](`L'activité à l'index ${i} est nulle.`);
continue;
}
[Link]([Link]);
[Link]();
await sleep(2000);
if ([Link] === "Multiple Choice") {
const choices = [Link]('[data-
qa=ChoiceButton]');
submitBtn = [Link]('[data-qa=SubmitButton]');
for (const choice of choices) {
[Link]();
await sleep(750);
[Link]();
await sleep(500);
submitBtn = [Link]('[data-
qa=SubmitButton]');
if ([Link] === 'Next Activity')
[Link]();
}
}
else if ([Link] == "Fill in the Blank") {
const menuBtns = [Link]('[data-qa =
MenuButton]');
for (const btn of menuBtns) {
[Link]();
await sleep(500);
const menuList = [Link]('[data-qa =
MenuList]').children;
menuList[getRandomInt(0, [Link] - 1)].click();
await sleep(250);
}
submitBtn = [Link]('[data-qa = SubmitButton]');
[Link]();
}
else if ([Link] == "Vocabulary" || [Link]
== "Explanation") {
const navForwardBtn = [Link]("[data-qa =
NavigateForwardButton]");
const listItem = [Link]("[data-qa =
ListItem]");
for (const item of listItem) {
[Link]();
await sleep(500);
}
submitBtn = [Link]('[data-qa = SubmitButton]');
[Link]();
}
else if ([Link] == "Matching") {
const texToDrag = [Link]("[data-
qa='DragDropText']");
const texToDragContainer =
[Link]('div[class*="DragDropTextContainer"]');
const indexs = generateRandomNumbers([Link]);
for (let i = 0; i < [Link]; i++) {
const I = indexs[i];
const text = texToDrag[I];
const container = texToDragContainer[i];
[Link](text);
await sleep(250);
}
await sleep(250 * [Link]);
submitBtn = [Link]('[data-qa = SubmitButton]');
[Link]();
}
else if ([Link] == "Arranging") {
const DraggableSentences = [Link]("[data-qa
= DraggableSentenceItem]");
if ([Link] > 0) {
const parent = DraggableSentences[0].parentElement;
for (const sentence of DraggableSentences) {
[Link](sentence);
}
submitBtn = [Link]('[data-qa =
SubmitButton]');
[Link]();
} else {
[Link]("Aucune phrase draggable trouvée.");
}
}
await sleep(1000);
}
await sleep(2000);
if ([Link]() - startTime >= maxDuration) {
[Link]("1 heure écoulée. Arrêt du script.");
return;
}
}
}
}
async function main() {
while (true) {
try {
await runAutomation();
break;
} catch (error) {
[Link]("Une erreur s'est produite, redémarrage :", error);
}
}
}
main();