r1411 / resh.edu fucker

// ==UserScript==
// @name         resh.edu fucker
// @namespace    https://resh.edu.ru/
// @version      0.2
// @description  Fuck this stupid tests
// @author       r1411
// @match        https://resh.edu.ru/subject/lesson/*/train*
// @grant        none
// @license MIT
// @copyright 2020, r1411
// ==/UserScript==

(function () {
  'use strict';

  function fuck() {
    let a = document.getElementsByClassName('test__task-num');
    a[a.length - 1].click();

    document.getElementsByClassName('lk-form-submit js-show-answer')[0].click();

    document.getElementsByClassName('lk-form-submit js-finish')[0].setAttribute('style', 'display: none;');
    document.getElementsByClassName('lk-form-submit js-show-answer')[0].removeAttribute('style');
    document.getElementsByClassName('lk-form-submit js-result')[0].removeAttribute('style');
    document.getElementsByClassName('lk-form-submit js-result')[0].innerText = 'Пройдено ' + a.length + ' из ' + a.length;
    document.getElementsByClassName('lk-form-submit js-show-answer')[0].click();
    Object.keys(a).forEach(function (key) {
      a[key].classList.add('test__task-num--passed');
      a[key].classList.remove('test__task-num--with-error');
    });
  }

  function onLoad() {
    let fuckBtn = document.createElement('a');
    fuckBtn.classList.add('lk-form-submit');
    fuckBtn.innerText = 'Ой, всё!!!';
    document.getElementsByClassName('d-tc header-top__logo-cell')[0].appendChild(fuckBtn);
    fuckBtn.addEventListener('click', function () {
      fuck();
      fuckBtn.innerText = 'Готово!'
    });
  }

  window.addEventListener('load', onLoad, false);
})();