VTU Auto Player

Full Automation Tool for Modules in Online VTU

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

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

})();