Duo's auto-comebacker

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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();