DriversEd Auto-Next with Stop Button

Auto-click the "Next" button when timer ends, with a Stop button to cancel auto-clicking.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         DriversEd Auto-Next with Stop Button
// @namespace    https://driversed.com/
// @version      1.0.1
// @description  Auto-click the "Next" button when timer ends, with a Stop button to cancel auto-clicking.
// @author       NellowTCS
// @match        https://app.driversed.com/*
// @grant        none
// @run-at       document-idle
// @license      MIT
// ==/UserScript==

(function () {
  'use strict';

  function waitAndClickNext() {
    const btn = document.getElementById('arrow-next');
    if (!btn) {
      console.warn('Next button not found, retrying...');
      setTimeout(waitAndClickNext, 500);
      return;
    }

    const observer = new MutationObserver(() => {
      if (!btn.disabled) {
        console.log('Next button enabled! Clicking now...');
        btn.click();
        observer.disconnect();
        removeStopButton();
      }
    });

    observer.observe(btn, { attributes: true, attributeFilter: ['disabled'] });
    console.log('Waiting for button to be enabled...');

    if (!document.getElementById('stop-auto-next')) {
      const stopBtn = document.createElement('button');
      stopBtn.id = 'stop-auto-next';
      stopBtn.textContent = 'Stop Auto-Next';
      stopBtn.style.position = 'fixed';
      stopBtn.style.bottom = '20px';
      stopBtn.style.right = '20px';
      stopBtn.style.zIndex = 10000;
      stopBtn.style.background = '#ff4d4d';
      stopBtn.style.color = '#fff';
      stopBtn.style.border = 'none';
      stopBtn.style.padding = '10px 14px';
      stopBtn.style.borderRadius = '6px';
      stopBtn.style.cursor = 'pointer';
      stopBtn.style.fontSize = '14px';
      stopBtn.style.boxShadow = '0 2px 6px rgba(0,0,0,0.2)';

      stopBtn.onclick = () => {
        observer.disconnect();
        console.log('Auto-clicker stopped manually.');
        removeStopButton();
      };

      document.body.appendChild(stopBtn);
    }

    function removeStopButton() {
      const existing = document.getElementById('stop-auto-next');
      if (existing) existing.remove();
    }
  }

  waitAndClickNext();
})();