Greasy Fork is available in English.

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

Finally, a MathsOnline Cheat after all these years!

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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