Duo's auto-comebacker

Need Duolingo-Cheat-Tool to working automaticly (https://update.greasyfork.org/scripts/431948/Duolingo-Cheat-Tool.user.js)

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Duo's auto-comebacker
// @namespace    http://tampermonkey.net/
// @version      v1.1
// @description  Need Duolingo-Cheat-Tool to working automaticly (https://update.greasyfork.org/scripts/431948/Duolingo-Cheat-Tool.user.js)
// @author       mhuy2k11
// @match        https://www.duolingo.com/learn
// @icon         https://www.google.com/s2/favicons?sz=64&domain=duolingo.com
// @grant        none
// ==/UserScript==

const startTime = Date.now();
async function run() {
  let link;
  // Thay số sau startTime nhỏ hơn để vào nhanh hơn
  while(!link && Date.now() - startTime < 1000){
    link = await waitForElement("#linkB");
  }
  if(link){
    location.replace('/practice'); //có thể chuyển /practice thành /lesson
  } else {
    setTimeout(() => {
      run();
    }, 1000);
  }
}

setTimeout(() => {
  document.body.innerHTML += '<div id="linkB"></div>';
}, 1000);
function waitForElement(selector) {
  return new Promise(resolve => {
    setTimeout(() => {
      if (document.querySelector(selector)) {
        resolve(document.querySelector(selector));
      }
    }, 1000);
  });
}
run();