Bypass class.forasm.com redirect

Immediately redirect to the target URL on class.forasm.com links

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Bypass class.forasm.com redirect
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Immediately redirect to the target URL on class.forasm.com links
// @author       wisp
// @license      MIT
// @runat        document-start
// @match        *://class.forasm.com/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    /**
     * Extract the encrypted parameter `o` from the URL hash.
     * @returns {string|null} The encrypted `o` value or null if not found.
     */
    function getEncryptedParam() {
        const hash = window.location.hash;
        const match = hash.match(/[?&]o=([^&]+)/);
        return match ? decodeURIComponent(match[1]) : null;
    }

    /**
     * Decrypt the encrypted parameter using the page's decryption logic.
     * @param {string} encrypted - The encrypted `o` parameter.
     * @param {string} key - The decryption key.
     * @returns {string|null} The decrypted URL or null if decryption fails.
     */
    function decryptUrl(encrypted, key) {
        try {
            return window.aesCrypto.decrypt(encrypted, key);
        } catch (error) {
            console.error('Error during decryption:', error);
            return null;
        }
    }

    /**
     * Extract and immediately redirect to the decrypted URL.
     */
    function extractAndRedirect() {
        const encryptedParam = getEncryptedParam();
        if (!encryptedParam) {
            console.error('Encrypted parameter "o" not found in the URL hash.');
            return;
        }

        console.log('Encrypted parameter found:', encryptedParam);

        // Use the hardcoded decryption key "root"
        const finalUrl = decryptUrl(encryptedParam, 'root');
        if (finalUrl) {
            console.log('Redirecting to final URL:', finalUrl);
            window.location.href = finalUrl; // Immediately redirect
        } else {
            console.error('Failed to decrypt the final URL.');
        }
    }

    // Execute immediately after script injection
    if (window.aesCrypto && typeof window.aesCrypto.decrypt === 'function') {
        extractAndRedirect();
    } else {
        console.error('aesCrypto.decrypt not available.');
    }
})();