Edge-nuity Megascript

Completes through instructional, summary, and warm-up sections by guessing answers (they don’t impact grades). You can begin activities while the instructor is speaking, when highlighting text, a "Search on Brainly" button appears for quick access to answers during quizzes. And much more (read desc).

目前為 2024-11-14 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Edge-nuity Megascript
// @version      0.3
// @description  Completes through instructional, summary, and warm-up sections by guessing answers (they don’t impact grades). You can begin activities while the instructor is speaking, when highlighting text, a "Search on Brainly" button appears for quick access to answers during quizzes. And much more (read desc).
// @author       TTT
// @license MIT
// @include *://*r16*/*
// @include https://brainly.com/*
// @grant        none
// @namespace https://www.tampermonkey.net/
// ==/UserScript==

function clickFootnavAndNextFrame() {
    try {
        document.getElementsByClassName("footnav goRight")[0].click();
    } catch (TypeError) {}

    try {
        window.frames[0].API.FrameChain.nextFrame();
    } catch (TypeError) {}
}

setInterval(function() {
    try {
        window.frames[0].document.getElementById("invis-o-div").remove();
    } catch (TypeError) {}
}, 1000);

let lastContainsAssignment = false;

function checkForAssignment() {
    const element = document.getElementById('activity-title');
    if (element) {
        const text = element.textContent || element.innerText;
        const currentContainsAssignment = text.includes("Assignment");
        if (!lastContainsAssignment && currentContainsAssignment) {
            new Notification("Done!");
        }
        lastContainsAssignment = currentContainsAssignment;
    }
}

setInterval(checkForAssignment, 1000);

function redirectToFirstSearchItem() {
    if (window.location.href.startsWith('https://brainly.com/app/ask')) {
        const searchItem = document.querySelector('[data-testid="search-item-facade-wrapper"]');
        if (searchItem) {
            const anchorElement = searchItem.querySelector('a');
            if (anchorElement) {
                const href = anchorElement.getAttribute('href');
                const fullUrl = `https://brainly.com${href}`;
                window.location.href = fullUrl;
                clearInterval(interval);
            }
        }
    }
}

const interval = setInterval(redirectToFirstSearchItem, 1000);

function clearLocalStorage() {
    try {
        localStorage.clear();
    } catch (error) {}
}

function removeElementsByClassName(className) {
    var elements = document.getElementsByClassName(className);
    Array.prototype.forEach.call(elements, function(element) {
        try {
            element.parentNode.removeChild(element);
        } catch (error) {}
    });
}

function handleOnload() {
    var classNamesToRemove = [
        "brn-expanded-bottom-banner",
        "brn-brainly-plus-box",
        "brn-fullscreen-toplayer",
        "sg-overlay sg-overlay--dark"
    ];
    classNamesToRemove.forEach(function(className) {
        removeElementsByClassName(className);
    });
}

if (window.location.href.includes("brainly.com")) {
    clearLocalStorage();
    window.onload = function() {
        try {
            handleOnload();
        } catch (error) {}
    };
}

(function() {
    if (window.self !== window.top) {
        var buttonContainer = document.createElement('div');
        buttonContainer.style.position = 'fixed';
        buttonContainer.style.top = '10px';
        buttonContainer.style.right = '10px';
        buttonContainer.style.zIndex = '9999';
        document.body.appendChild(buttonContainer);

        var clipboardButton = document.createElement('button');
        clipboardButton.innerText = 'Search Clipboard';
        buttonContainer.appendChild(clipboardButton);

        clipboardButton.onclick = function(event) {
            event.stopPropagation();
            navigator.clipboard.readText().then(function(clipboardText) {
                if (clipboardText) {
                    var searchUrl = 'https://brainly.com/app/ask?entry=top&q=' + encodeURIComponent(clipboardText);
                    window.open(searchUrl, '_blank');
                }
            }).catch(function(err) {});
        };
    }

    function showColumn() {
        try {
            window.frames[0].frames[0].document.getElementsByClassName("right-column")[0].children[0].style.display = "block";
        } catch (TypeError) {}

        try {
            window.frames[0].frames[0].document.getElementsByClassName("left-column")[0].children[0].style.display = "block";
        } catch (TypeError) {}
    }

    setInterval(showColumn, 1000);

    var searchButton = document.createElement('button');
    searchButton.id = 'searchButton';
    searchButton.innerText = 'Search on Brainly';
    searchButton.style.position = 'absolute';
    searchButton.style.visibility = 'hidden';
    document.body.appendChild(searchButton);

    searchButton.onclick = function(event) {
        event.stopPropagation();
        var selectedText = window.getSelection().toString();
        if (selectedText) {
            var searchUrl = 'https://brainly.com/app/ask?entry=top&q=' + encodeURIComponent(selectedText);
            window.open(searchUrl, '_blank');
        }
    };

    document.onmouseup = mouseUp;
    document.onmousedown = mouseDown;

    function mouseUp(event) {
        var selectedText = window.getSelection().toString();
        if (selectedText !== '') {
            searchButton.style.visibility = 'visible';
            searchButton.style.top = (event.clientY + 10) + 'px';
            searchButton.style.left = (event.clientX) + 'px';
        } else {
            searchButton.style.visibility = 'hidden';
        }
    }

    function mouseDown(event) {
        if (event.target !== searchButton && (window.self === window.top || event.target !== clipboardButton)) {
            searchButton.style.visibility = 'hidden';
            if (window.getSelection) {
                if (window.getSelection().empty) {
                    window.getSelection().empty();
                } else if (window.getSelection().removeAllRanges) {
                    window.getSelection().removeAllRanges();
                }
            } else if (document.selection) {
                document.selection.empty();
            }
        }
    }
})();

(function() {
    'use strict';

    let completeCount = 0;

    const originalConsoleLog = console.log;
    console.log = function() {
        const message = Array.from(arguments).join(' ');
        if (message.includes('complete')) {
            completeCount++;
            if (completeCount === 2) {
                const goRightButton = document.querySelector('li.FrameRight a');
                if (goRightButton) {
                    goRightButton.click();
                    completeCount = 0;
                }
            }
        }
        originalConsoleLog.apply(console, arguments);
    };
})();

setInterval(() => {
    const activityTitle = document.getElementById("activity-title").innerText;
    const homeVideoContainer = document.querySelector('.home-video-container');
    const shouldClick = !(
        homeVideoContainer &&
        homeVideoContainer.parentNode.style.opacity == "1"
    );

    if (shouldClick && !["Assignment", "Quiz"].includes(activityTitle)) {
        const goRightButton = document.querySelector(".FrameRight");
        if (goRightButton) {
            goRightButton.onclick();
        }
        const iconButton = document.querySelector(".nav-icon[data-bind='realEnable: $root.stageView().nextEnabled']");
        if (iconButton) {
            iconButton.click();
        }
    }
}, 1000);

function checkOpacity() {
    if (frames[0] && frames[0].document) {
        var homeVideoContainer = frames[0].document.getElementById("home_video_container");
        if (homeVideoContainer && homeVideoContainer.parentNode.style.opacity == 1) {
        } else {
            try {
                if (document.getElementById("activity-title").innerText == "Assignment") {}
                if (["Instruction", "Summary", "Warm-Up"].includes(document.getElementById("activity-title").innerText)) {
                    try {
                        clickFootnavAndNextFrame();
                        window.options = window.frames[0].frames[0].document.getElementsByClassName("answer-choice-button");
                        window.options[Math.floor(Math.random() * window.options.length)].click();
                    } catch (TypeError) {}
                    try {
                        window.frames[0].API.Frame.check();
                    } catch (TypeError) {}
                }
            } catch (TypeError) {}
        }
    }
}

setInterval(checkOpacity, 1000);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址