Duolingo auto practice

please download my other script [duohacker] for it to work properly.

当前为 2022-09-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Duolingo auto practice
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description please download my other script [duohacker] for it to work properly.
  6. // @author 0325skz
  7. // @copyright 0325skz
  8. // @match https://www.duolingo.com/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
  10. // @grant none
  11. // @run-at document-end
  12. // ==/UserScript==
  13.  
  14. const DEBUG = false;
  15.  
  16. let mainInterval;
  17. const TIME_OUT = 1000;
  18.  
  19. const TRIGGER_URL = "https://www.duolingo.com/learn"
  20.  
  21.  
  22. /*
  23. Make sure to start a language course before you run the farmer
  24.  
  25. Make sure that you have selected your language as your learning language on Duolingo,
  26. otherwise it will cause an error and be stuck in an infinite loop trying to start a lesson
  27. */
  28.  
  29.  
  30. function getLessonURL() {
  31. var redirect_url = "https://www.duolingo.com/practice"
  32. return redirect_url
  33. }
  34.  
  35. function redirect(url) {
  36. window.location.replace(url);
  37. if (DEBUG) { console.log("Redirected to:" + window.location)}
  38. }
  39.  
  40. function main() {
  41. if (DEBUG) { console.log("Running main")}
  42.  
  43. var currentLocation = window.location;
  44.  
  45. if (DEBUG) { console.log("Current location: " + currentLocation)}
  46.  
  47. if (currentLocation == TRIGGER_URL) {
  48. if (DEBUG) { console.log("Calling redirect")}
  49.  
  50. var new_lesson = getLessonURL();
  51. redirect(new_lesson);
  52. }
  53. }
  54.  
  55. function start() {
  56. mainInterval = setInterval(main, TIME_OUT)
  57. }
  58.  
  59. (start)();