MathsOnline CHEAT {CHEAT} {HACK} {EXPLOIT} {SPOOF}

Finally, a MathsOnline Cheat after all these years!

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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         MathsOnline CHEAT {CHEAT} {HACK} {EXPLOIT} {SPOOF}
// @namespace    https://tampermonkey.net
// @version      1.8
// @description  Finally, a MathsOnline Cheat after all these years!
// @author       Phil 🥹👍 and DynaHacks
// @license      MIT
// @match        *://www.mathsonline.com.au/*
// @match        *://www.mathsonline.com/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    console.log('%c[MathsOnline Cheat] MathsOnline Auto-Cheat loaded', 'color: #0066ff; font-weight: bold;');

    // Get tutorial (lesson ID)
    window.getTutorial = function() {
        let tutorial = null;

        // From URL (most reliable)
        const urlParams = new URLSearchParams(window.location.search);
        const pathParts = window.location.pathname.split('/');

        tutorial = urlParams.get('tutorial') || urlParams.get('tutorialId');

        // Extract from URL path like /lessons/102/3656
        if (!tutorial) {
            for (let i = 0; i < pathParts.length; i++) {
                if (pathParts[i] === 'lessons' && pathParts[i+1]) {
                    tutorial = pathParts[i+2] || pathParts[i+1]; // fallback
                    break;
                }
            }
        }

        // Fallback to global variables
        if (!tutorial && typeof window.tutorial !== 'undefined') tutorial = window.tutorial;
        if (!tutorial && window.currentQuestionSet) tutorial = window.currentQuestionSet.tutorial;

        console.log('%c[MathsOnline Cheat] Current tutorial:', tutorial);
        return tutorial;
    };

    // Get tutorialMaster (kept from before)
    window.getTutorialMaster = function() {
        let tutorialMaster = null;

        const urlParams = new URLSearchParams(window.location.search);
        tutorialMaster = urlParams.get('tutorialMaster') || urlParams.get('tutorialmaster');

        if (!tutorialMaster) {
            if (typeof window.tutorialMaster !== 'undefined') tutorialMaster = window.tutorialMaster;
            if (!tutorialMaster && window.currentQuestionSet) tutorialMaster = window.currentQuestionSet.tutorialMaster;
        }

        if (!tutorialMaster) {
            for (let key in window) {
                if (key.toLowerCase().includes('tutorialmaster') || key.toLowerCase().includes('tutorial_master')) {
                    const val = window[key];
                    if (typeof val === 'string' && /^\d+$/.test(val)) {
                        tutorialMaster = val;
                        break;
                    }
                }
            }
        }

        console.log('%c[MathsOnline Cheat] Current tutorialMaster:', tutorialMaster);
        return tutorialMaster;
    };

    function addCheatButton() {
        if (document.getElementById('cheat-btn')) return;

        const btn = document.createElement('button');
        btn.id = 'cheat-btn';
        btn.innerHTML = 'Send';
        btn.style.cssText = `
            position: fixed;
            top: 10px;
            right: 10px;
            z-index: 999999;
            padding: 6px 14px;
            background: #0066cc;
            color: white;
            border: none;
            border-radius: 4px;
            font-weight: bold;
            font-size: 13px;
            cursor: pointer;
            box-shadow: none;
            margin-left: 8px;
        `;

        btn.onmouseover = () => btn.style.background = '#0055aa';
        btn.onmouseout = () => btn.style.background = '#0066cc';

        btn.onclick = async () => {
            const tutorial = window.getTutorial();
            const tutorialMaster = window.getTutorialMaster();

            if (!tutorial || !tutorialMaster) {
                alert('Could not detect tutorial or tutorialMaster.\nMake sure you are inside an active lesson.');
                return;
            }

            console.log('%c[MathsOnline Cheat] Starting cheat → Tutorial:', tutorial, 'Master:', tutorialMaster);

            try {
                const startResponse = await fetch(
                    `https://www.mathsonline.com.au/ajax/svg_interactives/startQuestionSet?rid=${Math.random()}`,
                    {
                        method: 'POST',
                        headers: {
                            'Content-Type': 'application/x-www-form-urlencoded',
                            'X-Requested-With': 'XMLHttpRequest',
                        },
                        body: new URLSearchParams({
                            userQuestionSetTypeId: '7',
                            tutorial: tutorial,
                            tutorialMaster: tutorialMaster,
                            menuId: '102',
                            worksheetId: '0',
                            taskId: '0',
                            diagnosticTypeId: '0',
                        })
                    }
                );

                const startData = await startResponse.json();
                const { userQuestionSetId, svgInteractiveId } = startData;

                const submitResponse = await fetch(
                    `https://www.mathsonline.com.au/ajax/svg_interactives/submitResult?r=${Math.random()}`,
                    {
                        method: 'POST',
                        headers: {
                            'Content-Type': 'application/x-www-form-urlencoded',
                            'X-Requested-With': 'XMLHttpRequest',
                        },
                        body: new URLSearchParams({
                            userQuestionSetId,
                            svgInteractiveId,
                            tutorial: tutorial,
                            tutorialMaster: tutorialMaster,
                            menuId: '102',
                            worksheetId: '0',
                            diagnosticTypeId: '0',
                            userQuestionSetTypeId: '7',
                            difficulty: '1',
                            correct: 1,
                            incorrect: 0,
                            duration: Math.floor(8000 + Math.random() * 15000),
                            data: JSON.stringify([{
                                questionId: 1,
                                inputs: [{"id": "input1", "value": "42", "correct": "true"}],
                                checkboxes: [],
                                radiobuttons: [],
                                selectables: [],
                                draggables: [],
                                marks: [{"id": "mark1", "correct": "true"}],
                                solutions: []
                            }]),
                        })
                    }
                );

                const result = await submitResponse.json();
                console.log('%c[MathsOnline Cheat] Cheat successful!', result);

                // Auto reload to sync progress
                setTimeout(() => {
                    window.location.reload();
                }, 800);

            } catch (e) {
                console.error(e);
                alert('Cheat failed - check console for details.');
            }
        };

        document.body.appendChild(btn);
    }

    window.addEventListener('load', () => {
        setTimeout(addCheatButton, 1200);
    });

    console.log('%c[MathsOnline Cheat] Dynamic tutorial + tutorialMaster cheat ready.', 'color: #0066ff');
})();