LingoDeer Auto Write Myself

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         LingoDeer Auto Write Myself
// @namespace    https://greatest.deepsurf.us/users/649
// @version      1.0.3
// @description  Auto switch to "Write Myself", and adds press enter to continue.
// @author       Adrien Pyke
// @match        *://www.lingodeer.com/learn-languages/*
// @grant        none
// @require      https://cdn.jsdelivr.net/gh/fuzetsu/userscripts@ec863aa92cea78a20431f92e80ac0e93262136df/wait-for-elements/wait-for-elements.js
// ==/UserScript==

(() => {
  'use strict';

  let helpClicked = false;
  waitForElems({
    sel: '.switchBtn',
    onmatch: btn => {
      if (
        btn.textContent.trim() === 'I want to write it myself' &&
        !helpClicked
      )
        btn.click();
      else btn.addEventListener('click', () => (helpClicked = true));
      helpClicked = false;
    }
  });
  waitForElems({
    sel: '.textAreaInput textarea',
    onmatch: input => (
      input.addEventListener('keydown', e => {
        if (e.key !== 'Enter') return;
        const btn = document.querySelector(
          '.checkBtn.active, .continueBtn:not(.wrong)'
        );
        btn && btn.click();
        e.preventDefault();
        return false;
      }),
      input.focus()
    )
  });
  waitForElems({
    sel: '.signBtn',
    stop: true,
    onmatch: btn => btn.click()
  });
})();