LingoDeer Auto Write Myself

Auto switch to "Write Myself", and adds press enter to continue.

  1. // ==UserScript==
  2. // @name LingoDeer Auto Write Myself
  3. // @namespace https://greasyfork.org/users/649
  4. // @version 1.0.3
  5. // @description Auto switch to "Write Myself", and adds press enter to continue.
  6. // @author Adrien Pyke
  7. // @match *://www.lingodeer.com/learn-languages/*
  8. // @grant none
  9. // @require https://cdn.jsdelivr.net/gh/fuzetsu/userscripts@ec863aa92cea78a20431f92e80ac0e93262136df/wait-for-elements/wait-for-elements.js
  10. // ==/UserScript==
  11.  
  12. (() => {
  13. 'use strict';
  14.  
  15. let helpClicked = false;
  16. waitForElems({
  17. sel: '.switchBtn',
  18. onmatch: btn => {
  19. if (
  20. btn.textContent.trim() === 'I want to write it myself' &&
  21. !helpClicked
  22. )
  23. btn.click();
  24. else btn.addEventListener('click', () => (helpClicked = true));
  25. helpClicked = false;
  26. }
  27. });
  28. waitForElems({
  29. sel: '.textAreaInput textarea',
  30. onmatch: input => (
  31. input.addEventListener('keydown', e => {
  32. if (e.key !== 'Enter') return;
  33. const btn = document.querySelector(
  34. '.checkBtn.active, .continueBtn:not(.wrong)'
  35. );
  36. btn && btn.click();
  37. e.preventDefault();
  38. return false;
  39. }),
  40. input.focus()
  41. )
  42. });
  43. waitForElems({
  44. sel: '.signBtn',
  45. stop: true,
  46. onmatch: btn => btn.click()
  47. });
  48. })();