Enroll Class

11:49:50 9/12/2024

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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        Enroll Class
// @namespace   Enroll Class
// @match       https://fap.fpt.edu.vn/FrontOffice/MoveSubject.aspx*
// @grant       none
// @version     1.1
// @author      Eric Anti Code
// @description 11:49:50 9/12/2024
// ==/UserScript==

(function() {
    'use strict';

    const desiredText = "IA1702";
    const selectElement = document.getElementById("ctl00_mainContent_dllCourse");
    const saveButton = document.getElementById("ctl00_mainContent_btSave");

    if (selectElement) {
        if (selectElement.value === "49447") {
            saveButton.click();
            setTimeout(() => {
                location.reload();
            }, 1000);
        } else {
            for (let option of selectElement.options) {
                if (option.text === desiredText) {
                    selectElement.value = option.value;
                    const event = new Event('change', { bubbles: true });
                    selectElement.dispatchEvent(event);
                    break;
                }
            }

            setTimeout(() => {
                saveButton.click();
            }, 2000);
        }
    }

  function checkForError() {
        const errorMessage = document.querySelector('#cf-error-details h1');
        if (errorMessage && errorMessage.textContent.includes("Web server is returning an unknown error")) {
            location.reload(); 
        }
    }

  function checkForAlert() {
        const originalAlert = window.alert;
        window.alert = function(message) {
            location.reload();
            originalAlert(message);
        };
    }

    checkForAlert();

    setInterval(checkForError, 4000);
})();