Udacity "Next" clicker (Nanodegree program)

Don't tire yourself by pressing the Next button! You should only press "s" button.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Udacity "Next" clicker (Nanodegree program)
// @namespace    https://openuserjs.org/users/uzbek
// @licence      MIT
// @copyright    2021, Uzbek (https://openuserjs.org/users/uzbek)
// @version      1.1.1
// @description  Don't tire yourself by pressing the Next button! You should only press "s" button.
// @author       Uzbek
// @match        https://classroom.udacity.com/nanodegrees/nd*/*
// @icon         https://visualpharm.com/assets/890/Hacker-595b40b75ba036ed117d616b.svg
// @grant        none
// ==/UserScript==

(function () {
  'use strict';
  document.body.onkeypress = function (e) {
    if (e.code == 'KeyS') {
      sPressed();
    }
  };
})();

function sPressed() {
  if (document.querySelectorAll('.vds-modal').length > 0) {
    let elem = document.querySelectorAll(".vds-modal .vds-button.vds-button--primary");
    if (elem.length > 0) {
      elem[0].click();
      setTimeout(sPressed, 2000);
    }
    else {
      alert('No next button');
    }
  }
  else {
    let elem = document.querySelectorAll("._main--footer-container--3vC-_>button.vds-button.vds-button--secondary");
    if (elem.length > 0) {
      elem[0].click();
      setTimeout(sPressed, 2000);
    }
    else {
      let elem2 = document.querySelector('.index--lesson-card--mwX1V ._lesson-expanded--actions--KkY9y button.vds-button');
      if (elem2) {
        elem2.click();
        setTimeout(sPressed, 2000);
      }
      else {
        alert('No next button');
      }
    }
  }
}