DriversEd Auto-Next with Stop Button

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

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==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();
})();