Skolplus Cheat menu

Skolplus cheat

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

Advertisement:

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

Advertisement:

// ==UserScript==
// @name         Skolplus Cheat menu
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Skolplus cheat
// @author       ky2fff2
// @match        https://skolplus.se/*
// @grant        GM_setValue
// @grant        GM_getValue
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    let answerActive = GM_getValue('answerActive', false);
    let theme = GM_getValue('theme', 'dark'); // 'dark' or 'light'

    const createMenu = () => {
        const menu = document.createElement('div');
        menu.id = 'skolplus-cheat-menu';
        menu.style.cssText = `
            position: fixed;
            bottom: 20px;
            right: 20px;
            z-index: 9999;
            font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
            font-size: 14px;
        `;

        const toggle = document.createElement('button');
        toggle.id = 'cheat-toggle';
        toggle.textContent = '⚡';
        toggle.style.cssText = `
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: ${theme === 'dark' ? '#2c3e50' : '#f1f1f1'};
            color: ${theme === 'dark' ? '#ecf0f1' : '#2c3e50'};
            border: none;
            cursor: pointer;
            font-size: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 2px 10px rgba(0,0,0,0.2);
            transition: all 0.2s ease;
        `;

        const panel = document.createElement('div');
        panel.id = 'cheat-panel';
        panel.style.cssText = `
            position: absolute;
            bottom: 50px;
            right: 0;
            width: 220px;
            background: ${theme === 'dark' ? '#2c3e50' : '#ffffff'};
            color: ${theme === 'dark' ? '#ecf0f1' : '#2c3e50'};
            border-radius: 12px;
            padding: 12px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.15);
            display: none;
            flex-direction: column;
            gap: 10px;
            backdrop-filter: blur(10px);
            border: 1px solid ${theme === 'dark' ? '#34495e' : '#e0e0e0'};
        `;

        const titleBar = document.createElement('div');
        titleBar.style.cssText = `
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 5px;
            font-weight: bold;
            border-bottom: 1px solid ${theme === 'dark' ? '#34495e' : '#e0e0e0'};
            padding-bottom: 5px;
        `;
        titleBar.innerHTML = `<span>Cheat Menu</span><button id="theme-toggle" style="background:none; border:none; cursor:pointer; font-size:16px;">${theme === 'dark' ? 'Light' : 'Dark'}</button>`;

        const answerBtn = document.createElement('button');
        answerBtn.textContent = `🔍 Show Answer: ${answerActive ? 'ON' : 'OFF'}`;
        answerBtn.style.cssText = `
            background: ${answerActive ? '#e67e22' : '#7f8c8d'};
            border: none;
            padding: 8px;
            border-radius: 8px;
            color: white;
            cursor: pointer;
            font-weight: bold;
            transition: 0.1s;
        `;

        const autoSolveBtn = document.createElement('button');
        autoSolveBtn.textContent = '🤖 Auto-Solve';
        autoSolveBtn.style.cssText = `
            background: #3498db;
            border: none;
            padding: 8px;
            border-radius: 8px;
            color: white;
            cursor: pointer;
            font-weight: bold;
        `;

        const addPointsBtn = document.createElement('button');
        addPointsBtn.textContent = '⭐ +100 Points';
        addPointsBtn.style.cssText = `
            background: #2ecc71;
            border: none;
            padding: 8px;
            border-radius: 8px;
            color: white;
            cursor: pointer;
            font-weight: bold;
        `;

        const status = document.createElement('div');
        status.style.cssText = `
            font-size: 12px;
            text-align: center;
            margin-top: 5px;
            opacity: 0.8;
        `;
        status.textContent = 'Ready';

        panel.appendChild(titleBar);
        panel.appendChild(answerBtn);
        panel.appendChild(autoSolveBtn);
        panel.appendChild(addPointsBtn);
        panel.appendChild(status);
        menu.appendChild(toggle);
        menu.appendChild(panel);
        document.body.appendChild(menu);

        // Toggle panel
        toggle.addEventListener('click', () => {
            panel.style.display = panel.style.display === 'none' ? 'flex' : 'none';
        });

        // Theme toggle
        document.getElementById('theme-toggle').addEventListener('click', () => {
            theme = theme === 'dark' ? 'light' : 'dark';
            GM_setValue('theme', theme);
            updateTheme();
        });

        // Answer toggle
        answerBtn.addEventListener('click', () => {
            answerActive = !answerActive;
            GM_setValue('answerActive', answerActive);
            answerBtn.textContent = `🔍 Show Answer: ${answerActive ? 'ON' : 'OFF'}`;
            answerBtn.style.background = answerActive ? '#e67e22' : '#7f8c8d';
            status.textContent = answerActive ? 'Answer reveal enabled' : 'Answer reveal disabled';
            setTimeout(() => { status.textContent = 'Ready'; }, 1500);
            if (answerActive) revealAnswers();
        });

        // Auto-solve
        autoSolveBtn.addEventListener('click', () => {
            status.textContent = 'Solving...';
            autoSolve();
            status.textContent = 'Solved!';
            setTimeout(() => { status.textContent = 'Ready'; }, 1500);
        });

        // Add points
        addPointsBtn.addEventListener('click', () => {
            status.textContent = 'Adding points...';
            addPoints();
            status.textContent = 'Points added!';
            setTimeout(() => { status.textContent = 'Ready'; }, 1500);
        });
    };

    const updateTheme = () => {
        const menu = document.getElementById('skolplus-cheat-menu');
        if (!menu) return;
        const toggle = document.getElementById('cheat-toggle');
        const panel = document.getElementById('cheat-panel');
        const themeBtn = document.getElementById('theme-toggle');
        if (theme === 'dark') {
            toggle.style.background = '#2c3e50';
            toggle.style.color = '#ecf0f1';
            panel.style.background = '#2c3e50';
            panel.style.color = '#ecf0f1';
            panel.style.borderColor = '#34495e';
            themeBtn.innerHTML = 'Light';
        } else {
            toggle.style.background = '#f1f1f1';
            toggle.style.color = '#2c3e50';
            panel.style.background = '#ffffff';
            panel.style.color = '#2c3e50';
            panel.style.borderColor = '#e0e0e0';
            themeBtn.innerHTML = 'Dark';
        }
    };

    const revealAnswers = () => {
        // Scan for common answer containers
        const selectors = [
            'input[type="text"]', 'input[type="number"]', 'textarea',
            '.answer', '.correct-answer', '.solution', '[data-answer]',
            '.quiz-answer', '.exercise-answer', '.result'
        ];
        selectors.forEach(sel => {
            document.querySelectorAll(sel).forEach(el => {
                if (el.value !== undefined && !el._cheatHighlighted) {
                    if (el.value === '') {
                        // Try to guess answer from data attributes
                        const answer = el.getAttribute('data-answer') || el.getAttribute('data-correct');
                        if (answer) {
                            el.value = answer;
                            el.style.border = '2px solid #e67e22';
                            el._cheatHighlighted = true;
                        }
                    }
                } else if (el.innerText && !el._cheatHighlighted) {
                    if (el.innerText.includes('Rätt svar') || el.innerText.includes('Correct answer')) {
                        const match = el.innerText.match(/\d+/);
                        if (match) {
                            const answerInput = el.closest('div')?.querySelector('input');
                            if (answerInput && answerInput.value === '') {
                                answerInput.value = match[0];
                                answerInput.style.border = '2px solid #e67e22';
                                answerInput._cheatHighlighted = true;
                            }
                        }
                        el.style.backgroundColor = '#e67e22';
                        el._cheatHighlighted = true;
                    }
                }
            });
        });
        if (answerActive) setTimeout(revealAnswers, 2000);
    };

    const autoSolve = () => {
        // Attempt to automatically answer multiple choice or fill-in questions
        document.querySelectorAll('input[type="radio"], input[type="checkbox"]').forEach(radio => {
            if (radio.hasAttribute('data-correct') && radio.getAttribute('data-correct') === 'true') {
                radio.checked = true;
                radio.dispatchEvent(new Event('change', { bubbles: true }));
            } else {
                // Fallback: guess the first option
                if (!radio.checked && radio.value && !radio.closest('.question')?.querySelector('input:checked')) {
                    radio.checked = true;
                    radio.dispatchEvent(new Event('change', { bubbles: true }));
                }
            }
        });
        document.querySelectorAll('select').forEach(select => {
            const correctOption = Array.from(select.options).find(opt => opt.hasAttribute('data-correct') && opt.getAttribute('data-correct') === 'true');
            if (correctOption) {
                select.value = correctOption.value;
                select.dispatchEvent(new Event('change', { bubbles: true }));
            } else if (select.options.length > 0) {
                select.selectedIndex = 0;
                select.dispatchEvent(new Event('change', { bubbles: true }));
            }
        });
        document.querySelectorAll('button[type="submit"], .submit-btn, .next-btn, .continue-btn').forEach(btn => {
            if (btn.offsetParent !== null) btn.click();
        });
        revealAnswers(); // Also fill any text inputs if possible
    };

    const addPoints = () => {
        // Try to increment score or simulate a correct answer event
        const scoreElements = document.querySelectorAll('.score, .points, .stars, [data-score]');
        scoreElements.forEach(el => {
            let current = parseInt(el.innerText) || 0;
            if (!isNaN(current)) {
                el.innerText = current + 100;
                if (el.hasAttribute('data-score')) el.setAttribute('data-score', current + 100);
                el.dispatchEvent(new Event('change', { bubbles: true }));
            }
        });
        // Try to find a "correct" event emitter
        const correctBtn = document.querySelector('.correct, .right-answer, .good-job');
        if (correctBtn) correctBtn.click();
        // Simulate keyboard shortcut for correct answer if any
        document.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight', ctrlKey: true }));
    };

    const handleKeyPress = (e) => {
        if ((e.ctrlKey || e.metaKey) && e.key === 'x') {
            e.preventDefault();
            const toggle = document.getElementById('cheat-toggle');
            if (toggle) toggle.click();
        } else if ((e.altKey) && e.key === 'x') {
            e.preventDefault();
            const toggle = document.getElementById('cheat-toggle');
            if (toggle) toggle.click();
        }
    };

    window.addEventListener('load', () => {
        createMenu();
        updateTheme();
        document.addEventListener('keydown', handleKeyPress);
        if (answerActive) revealAnswers();
    });
})();