VTU Auto Player

Full Automation Tool for Modules in Online VTU

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         VTU Auto Player
// @namespace    http://tampermonkey.net/
// @version      9.0
// @description  Full Automation Tool for Modules in Online VTU
// @match        https://online.vtu.ac.in/*
// @grant        none
// @run-at       document-idle
// @license All Rights Reserved
// ==/UserScript==

(function () {
  'use strict';

  console.log("✅ VTU Automation Loaded");

  const SPEED = 2;
  window.LF_RUNNING = true;

  /***********************
   * YOUTUBE CONTROL
   ***********************/
  function getIframe() {
    return document.querySelector("iframe[src*='youtube']");
  }

  function sendCommand(func, args = []) {
    const iframe = getIframe();
    if (!iframe) {
      console.log("⏳ Waiting for YouTube iframe...");
      return;
    }

    iframe.contentWindow.postMessage(JSON.stringify({
      event: "command",
      func,
      args
    }), "*");
  }

  function setSpeed() {
    sendCommand("setPlaybackRate", [SPEED]);
  }

  function play() {
    sendCommand("playVideo");
  }

  /***********************
   * LECTURE DETECTION
   ***********************/
  function getLectures() {
    return Array.from(document.querySelectorAll(".cursor-pointer"))
      .filter(el => el.innerText.includes("Lecture"));
  }

  function isCurrent(el) {
    return el.innerText.includes("Playing");
  }

  function isCompleted(el) {
    return el.querySelector(".text-emerald-600") !== null;
  }

  function getCurrentLecture() {
    return getLectures().find(isCurrent);
  }

  /***********************
   * CLICK FIX
   ***********************/
  function clickLecture(el) {
    el.scrollIntoView({ behavior: "smooth", block: "center" });

    setTimeout(() => {
      el.dispatchEvent(new MouseEvent("click", { bubbles: true }));
    }, 800);
  }

  /***********************
   * NEXT LECTURE LOGIC
   ***********************/
  function goNext() {
    console.log("➡ Moving to next lecture...");

    const lectures = getLectures();
    let found = false;

    for (let lec of lectures) {
      if (found && !isCompleted(lec)) {
        clickLecture(lec);
        return;
      }

      if (isCurrent(lec)) {
        found = true;
      }
    }

    console.log("📦 Trying next week...");

    const weeks = document.querySelectorAll('[data-state="closed"] button');
    if (weeks.length > 0) {
      weeks[0].click();

      setTimeout(() => {
        const next = getLectures().find(l => !isCompleted(l));
        if (next) clickLecture(next);
      }, 2000);
    }
  }

  /***********************
   * DONATION POPUP (QR)
   ***********************/
  function showQR() {
      alert(`
⏳ You just saved hours of manual work.

Support = more features, better updates 🚀

Even ₹100 makes a difference ❤️

`);
    if (document.getElementById("lf-qr")) return;

    const div = document.createElement("div");
    div.id = "lf-qr";
    div.innerHTML = `
      <div style="
        position: fixed;
        top: 30%;
        left: 40%;
        background: white;
        padding: 20px;
        border-radius: 10px;
        z-index: 10000;
        text-align: center;
        box-shadow: 0 0 10px rgba(0,0,0,0.3);
      ">
        <p>Support ❤️</p>
        <img src="https://i.postimg.cc/rFZCCCWW/coffee.jpg" width="180">
        <br><br>
        <button id="lf-close" style="
        background: black;
        border-radius: 10px;
        z-index: 10000;
        width: 160px;
        font-family: Arial;
        color: red;
        ">Close</button>
      </div>
    `;

    document.body.appendChild(div);

    document.getElementById("lf-close").onclick = () => div.remove();
  }

  /***********************
   * UI PANEL
   ***********************/
  function createUI() {
    const panel = document.createElement("div");
    panel.innerHTML = `
      <div id="lf-panel">
        <h3>LectureFlow</h3>
        <button id="lf-toggle">Start</button>
        <button id="lf-donate">Donate ❤️</button>
        <p>Status: <span id="lf-status">OFF</span></p>
      </div>
    `;

    document.body.appendChild(panel);

    const style = document.createElement("style");
    style.innerHTML = `
      #lf-panel {
        position: fixed;
        bottom: 20px;
        right: 20px;
        background: #111;
        color: white;
        padding: 12px;
        border-radius: 10px;
        z-index: 9999;
        width: 160px;
        font-family: Arial;
      }

      #lf-panel button {
        width: 100%;
        margin-top: 6px;
        padding: 6px;
        border: none;
        border-radius: 5px;
        cursor: pointer;
      }

      #lf-toggle {
        background: #22c55e;
        color: white;
      }

      #lf-donate {
        background: #f59e0b;
        color: black;
      }
    `;

    document.head.appendChild(style);

    let running = false;

    document.getElementById("lf-toggle").onclick = () => {
      running = !running;
      window.LF_RUNNING = running;

      document.getElementById("lf-status").innerText = running ? "ON" : "OFF";
      document.getElementById("lf-toggle").innerText = running ? "Stop" : "Start";
    };

    document.getElementById("lf-donate").onclick = showQR;
  }

  /***********************
   * MAIN LOOP
   ***********************/
  setInterval(() => {
  if (!window.LF_RUNNING) return;
    setSpeed();
    play();

    const current = getCurrentLecture();
    if (!current) return;

    if (isCompleted(current)) {
      goNext();
    }

  }, 3000);

  /***********************
   * INIT
   ***********************/
  createUI();

  // Show donation message once
  if (!localStorage.getItem("lf_donated_msg")) {
    setTimeout(() => {
      showQR();
      localStorage.setItem("lf_donated_msg", "1");
    }, 60000);
  }

})();