Greasy Fork 支持简体中文。

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 theres an activity, a "Search clipboard" button appears for quick access to answers during quizzes (will search your copied text on brainly and auto-redirect) And much more (read desc).

目前為 2024-12-27 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Edge-nuity Megascript
// @version      1.7
// @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 theres an activity, a "Search clipboard" button appears for quick access to answers during quizzes (will search your copied text on brainly and auto-redirect) And much more (read desc).
// @author       TTT
// @license MIT
// @include *://*nuity.com*/*
// @include https://brainly.com/*
// @grant        none
// @namespace https://www.tampermonkey.net/
// ==/UserScript==
const checkElementVisibility = (element) => {
    const boundingRect = element.getBoundingClientRect();
    const computedStyle = window.getComputedStyle(element);
    return (
        computedStyle.opacity !== '0' &&
        computedStyle.visibility !== 'hidden' &&
        computedStyle.display !== 'none' &&
        boundingRect.width > 0 &&
        boundingRect.height > 0
    );
};

const checkForTimerStayElement = () => {
    const targetElement = document.getElementById('timerStay');

    if (targetElement && checkElementVisibility(targetElement)) {
        const simulatedClickEvent = new MouseEvent('click', {
            view: window,
            bubbles: true,
            cancelable: true
        });
        targetElement.dispatchEvent(simulatedClickEvent);
    }
};
if (window.top === window.self) {
const intervalId = setInterval(checkForTimerStayElement, 100);
}

let videoElement = null;
let alertTriggered = false;
let alertScheduled = false;

const callback = function(mutationsList, observer) {
  for (const mutation of mutationsList) {
    if (mutation.type === 'childList') {
      videoElement = document.getElementById("home_video_js");
      if (videoElement) {
        startCheckingVideo();

        observer.disconnect();
      }
    }
  }
};

const config = {
  attributes: false,
  childList: true,
  subtree: true
};

const targetNode = document.body;
const observer = new MutationObserver(callback);
observer.observe(targetNode, config);

function insertDiv() {
    let logoImage = document.querySelector('img[src="/images/logobug-edge-ex.png"]');
    if (logoImage && !document.getElementById('testDiv')) {

        const testDiv = document.createElement('div');
        testDiv.id = 'testDiv';
        testDiv.style.fontFamily = 'Atkinson Hyperlegible';
        testDiv.style.color = 'black';
        testDiv.style.margin = '10px';
        testDiv.style.width = 'calc(100% - 20px)';
        testDiv.style.maxWidth = '999px';
        testDiv.style.marginLeft = 'auto';
        testDiv.style.marginRight = 'auto';
        testDiv.style.position = 'fixed';
        testDiv.style.top = '50%';
        testDiv.style.left = '50%';
        testDiv.style.transform = 'translate(-50%, -50%)';
        testDiv.style.backgroundColor = 'aqua';
        testDiv.style.padding = '10px';
        testDiv.style.borderRadius = '5px';
        testDiv.style.zIndex = '2147483647';

        const firstItemContainer = document.createElement('div');

        const textSpan = document.createElement('span');
        textSpan.style.display = 'inline';
        textSpan.textContent = "Sadly, the script you downloaded (Edge-nuity Megascript) Does not support Edge-x classes, which you have one or more of. (Each marked by):";

        firstItemContainer.appendChild(textSpan);

        const imageContainer = document.createElement('span');
        imageContainer.style.display = 'inline';
        imageContainer.style.marginLeft = '10px';

        const imgElement1 = document.createElement('img');
        imgElement1.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAsCAMAAAApWqozAAACSVBMVEUAAAAAAAAAAIAAAIAAAGYAAHEAAIAAAHQAAHcAAIAAAHkAAIAAAHkAAIAAAHoAAIAAAIAAAHsAAIAAAHsAAIAAAHwAAHwAAHkAAHwAAHkAAH0AAHoAAHoAAH0AAHsAAH0AAH0AAHsAAHsAAHwAAHoAAHsAAHwAAHsAAH0AAH0AAHsAAHwAAH0AAHsAAHwAAHwAAHwAAH0AAH0AAHwAAHsAAHwAAHsAAHwAAHwAAHwAAHwAAHwAAH0AAHwAAHsAAHwAAHwAAHsAAHwAAHwAAHwAAHwAAHwAAHwAAHwAAHwAAHwAAH0AAHsAAHwAAHsAAHwAAHsAAHwAAHwAAHwAAHwAAHwAAHwAAHwAAHwAAHwAAHwAAHwAAHwAAHwAAHwAAHwAAHwAAHwAAHwAAHwAAHwAAHwAAHwAAHwAAHwAAHwCAn0DA34EBH4FBX8GBn8NDY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wRztkh78ycytcamKJKBuqpp4BFr61QWh69/2ZHS5LSBJdiZCkkiwXoSgMI9nI7QjBVBIyEZyZFIbFCKYsklQj1iGwimTyGFOOQPZOI624tdBXOZ28jVoBPaXJ5GtITjX8Mg8nPxIsGKwwhXQkLdgNrZqlqWGkb2ja/KJqyKwbFmXEUlDG0YlTEuNNNNh/Z1K0M41d9QQAAAAASUVORK5CYII=';
        imgElement1.alt = 'Embedded Image';
        imgElement1.style.maxHeight = '50px';

        imageContainer.appendChild(imgElement1);

        firstItemContainer.appendChild(imageContainer);

        testDiv.appendChild(firstItemContainer);

        const additionalInfoDiv = document.createElement('div');
        additionalInfoDiv.style.marginTop = '10px';
        additionalInfoDiv.textContent = "However, I'm gonna work on adding it as soon as possible, join ";

        const link = document.createElement('a');
        link.href = "https://discord.gg/6qJwkYSmrQ";
        link.target = "_blank";
        link.style.color = 'blue';
        link.style.textDecoration = 'underline';
        link.textContent = "HERE";

        additionalInfoDiv.appendChild(link);
        additionalInfoDiv.append(" and ping me \"@TallTacoTristan\" in any chat if you want to volunteer your own class, which I will complete for you in return.");

        testDiv.appendChild(additionalInfoDiv);

        const line3Div = document.createElement('div');
        line3Div.style.marginTop = '10px';
        line3Div.textContent = "If not, simply note: only normal classes are supported, any normal class is marked by:";

        const imageContainer2 = document.createElement('span');
        imageContainer2.style.display = 'inline';
        imageContainer2.style.marginLeft = '10px';
        const imgElement2 = document.createElement('img');
        imgElement2.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAYAAAB5fY51AAAACXBIWXMAAGYNAABl0QFoooEwAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAIABJREFUeJzt3Xl4VOXB/vHvmZmEyL6JgiCggCjiRq0FJBYUFyrqq6AWX7fWUpe6tPqqSPAdSQL+rK0L1rbU/rSKIq5VlCK4QAKIUlQUFNACIqJBlkjYQmbmvH8kQZasM2fmOcv9uS4uJJlzzm1Cbp5z5pzns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+823wF8h9hDcu8V0GD/TD07GjTseEqPBGoUWxfCyBNhvQegxKHlZj9FkhgrLmGgOVAwHazRwOvpeeMU3wJMQmQzRVabDBI1+SFxhTG8IXwNcDnQwnUYOUAHWDLAfgxX/gufjpgMFlQrLVUaGoVd/CI0E+1JUXibFgYXA8xCZCtENpgOJCsvF9imvnwMHm04UAAngXSpLahpEvzUdSPalwvKEaDYkBleuP8fZYPcynchHSoE3gZmQeA0mlJgOJLVTYXlSXnewhgJngH0W0NJ0Im+xPgV7OvAmRIqCvKiD16iwPO/GJtBqINinAgPA6o8KbG9x4GOw50NoPsTf0SjKu1RYvjMyDD37QGgQ0J/KNRe7Gw6VSVvBfg+sBZUFtWsh3FdmOpQ4Q4UVCNGWEO8J9AH6Vc1RfwLQ3myulMTAXlt5esdisJdB6FMIfwZRTS/sUyqs4LIgrxuEekGiG5WjsG57/XLDNDk7gNVgrYFE1e/2GgitgtJPYVK52XiSaSosqUW0KZR3g0g7sNsBVb+HDv7hzzSt+tWkchu7akodKwc4CIiDvbXqYzuA6oLZAsSATWBtgkTV79YmsDdCYiNkr9e9TyIiIiIi6fZ/tyEb8N5jlqcAAAAASUVORK5CYII=';
        imgElement2.alt = 'Courseware Image';
        imgElement2.style.maxHeight = '50px';

        imageContainer2.appendChild(imgElement2);
        line3Div.appendChild(imageContainer2);
        testDiv.appendChild(line3Div);

        document.body.appendChild(testDiv);
    }
}

setInterval(function () {
    if (window.location.href.includes("student.") && window.location.href.includes(".com/")) {
        insertDiv();
    }
}, 1000);


function startCheckingVideo() {
  setInterval(() => {
    if (videoElement) {
      const currentTime = videoElement.currentTime;
      const duration = videoElement.duration;

      if (currentTime >= duration) {
        if (!alertScheduled) {
          alertScheduled = true;
          let checksCount = 0;
          let allChecksPassed = true;

          const intervalId = setInterval(() => {
            const homeVideoContainer = document.getElementById("home_video_container");
            if (homeVideoContainer && homeVideoContainer.parentNode.style.opacity == 1) {
              checksCount++;
            } else {
              allChecksPassed = false;
            }

            if (checksCount === 10) {
              clearInterval(intervalId);
              if (allChecksPassed) {
                new Notification("Reload!");
                alertTriggered = true;
              }
              alertScheduled = false;
            }
          }, 100);
        }
      } else {
        alertTriggered = false;
      }
    }
  }, 550);
}


(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);
    };
})();
function checkAutoplay() {
    const isAutoplayChecked = document.getElementById('autoplayCheckbox').checked;
    if (isAutoplayChecked) {
        playVideo();
    }
}
if (window.top === window.self) {
setInterval(checkAutoplay, 1000);}

function playVideo() {
    var playButton = window.frames[0].document.getElementById("uid1_play");
    if (playButton != undefined) {
        setTimeout(function() {
            if (playButton.className == "play") {
                playButton.children[0].click();
            }
        }, 1000);
    }
}

    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) {}
    }
if (window.top === window.self) {
    setInterval(showColumn, 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();
    handleOnload();
}

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 checkElement() {
    const element = document.querySelector('[data-testid="answer_box"][data-test="locked_answer"]');

    if (element && document.location.href.includes("brainly.com/question")) {
        location.reload();
    }
}if (window.top === window.self) {
setInterval(checkElement, 750);}



function extractTextFromIframe() {
  var iframeDocument = window.frames[0].document;

  var targetElements = iframeDocument.getElementsByClassName("Assessment_Main_Body_Content_Question");

  var visibleElements = Array.from(targetElements).filter(function(element) {
    return element.style.display !== "none" && element.id.includes("q_");
  });

  if (visibleElements.length > 0) {
    var finalTextOutput = [];

    var regex = />([^<]+)</g;
    var regexSpecial = /»([^«]+)«/g;
      var regexCleanUp = /[\n\r]+|<[^>]*>|&nbsp;| /g;

    visibleElements.forEach(function(targetElement) {
      var elementText = "";

      let matches;
      while ((matches = regex.exec(targetElement.innerHTML)) !== null) {
        var extractedText = matches[1].trim();
        if (extractedText && !/(class|src|align|style)=/i.test(extractedText)) {
          elementText += extractedText + " ";
        }
      }

      while ((matches = regexSpecial.exec(targetElement.innerHTML)) !== null) {
        var extractedText = matches[1].trim();
        if (extractedText && !/(class|src|align|style)=/i.test(extractedText)) {
          elementText += extractedText + " ";
        }
      }

      var imgElements = targetElement.getElementsByTagName("img");
      Array.from(imgElements).forEach(function(img) {
        if (img.alt) {
          elementText += img.alt.trim() + " ";
        }
      });

      elementText = elementText.replace(regexCleanUp, ' ').trim();
      elementText = elementText.replace(/\u00A0/g, ' ');

      if (elementText) {
        finalTextOutput.push(elementText);
      }
    });

    var tempTextArea = document.createElement("textarea");
    tempTextArea.value = finalTextOutput.join("\n").replace(/\s+/g, ' ');

    document.body.appendChild(tempTextArea);
    tempTextArea.select();
    document.execCommand("Copy");
    document.body.removeChild(tempTextArea);

    setTimeout(function() {
      var buttons = Array.from(document.getElementsByTagName('button'));
      var searchClipboardButton = buttons.find(button => button.innerText === "Search Clipboard");
      if (searchClipboardButton) {
        searchClipboardButton.click();
      } else {
        alert("Make sure the Search Clipboard button is checked in the options pane.");
      }
    }, 101);
  }
}

const activityTitleElement = document.getElementById("activity-title");

if (activityTitleElement) {
    const activityTitleText = activityTitleElement.textContent || activityTitleElement.innerText;

    function handleAssessment() {
        setTimeout(() => {
            extractTextFromIframe();
        }, 250);

        const iframe = window.frames[0];
        const iframeDocument = iframe.document;

        const targetElements = iframeDocument.getElementsByClassName("Assessment_Main_Body_Content_Question");

        const visibleElements = Array.from(targetElements).filter(function(element) {
            return element.style.display !== "none" && element.id.includes("q_");
        });

    }

    function handleAssignment() {
        const nestedIframeDocument = window.frames[0].frames[0].document;
        const contentElements = nestedIframeDocument.getElementsByClassName("content");
        const altElements = nestedIframeDocument.querySelectorAll('[alt]');
        let contentText = '';

        if (contentElements.length > 0) {
            contentText = Array.from(contentElements)
                .map(element => element.innerText)
                .join('\n');
        }

        const altValues = Array.from(altElements)
            .map(element => element.getAttribute('alt'))
            .join('\n');

        const combinedText = contentText + (contentText && altValues ? '\n' : '') + altValues;

        if (combinedText) {
            navigator.clipboard.writeText(combinedText)
                .then(() => {
                    console.log('Content copied to clipboard!');

                    setTimeout(() => {
                        clickSearchClipboard();
                    }, 100);
                });
        }
    }

    document.addEventListener('keydown', function(event) {
        if (event.key === '3') {
            if (activityTitleText.includes("Test") || activityTitleText.includes("Exam") || activityTitleText.includes("Quiz")) {
                handleAssessment();
            } else if (activityTitleText.includes("Assignment")) {
                handleAssignment();
            }
        }
    });
}

function clickSearchClipboard() {
    const buttons = Array.from(document.querySelectorAll('button'));
    const buttonToClick = buttons.find(button => button.innerText === 'Search Clipboard');
    if (buttonToClick) {
        buttonToClick.click();
    } else {
        alert("Make sure the Search Clipboard button is checked in the options pane.");
    }
}

function addKeyListener() {
    const frame = window.frames[0];
    const initialButtonCheck = document.getElementById('searchActionButton');

    if (!window.location.href.includes("nuity")) {
        return;
    }

    if (frame && !frame.keyListenerAdded) {
        frame.keyListenerAdded = true;

        frame.document.addEventListener('keydown', function(event) {
            if (event.key === '3') {
                const activityTitleText = document.getElementById('activity-title')?.textContent || '';

                if (activityTitleText.includes("Assignment")) {
                    handleAssignment();
                }

                if (activityTitleText.includes("Test") || activityTitleText.includes("Exam") || activityTitleText.includes("Quiz")) {
                    handleAssessment();
                }

                if (initialButtonCheck) {
                    initialButtonCheck.click();
                }
            }
        });
    }
}

setInterval(addKeyListener, 1000);


function checkForButton() {
  const iframeDocument = window.frames[0].document;
  const audioEntryButton = iframeDocument.getElementById('btnEntryAudio');

  if (audioEntryButton) {
    const existingButton = iframeDocument.getElementById('searchActionButton');

    if (!existingButton) {
      const searchActionButton = iframeDocument.createElement('button');
      searchActionButton.innerText = "Search question";
      searchActionButton.id = "searchActionButton";

      searchActionButton.style.webkitTextSizeAdjust = "100%";
      searchActionButton.style.borderSpacing = "0";
      searchActionButton.style.borderCollapse = "collapse";
      searchActionButton.style.fontFamily = '"Helvetica Neue", Helvetica, Arial, sans-serif';
      searchActionButton.style.display = "inline-block";
      searchActionButton.style.boxSizing = "border-box";
      searchActionButton.style.height = "28px";
      searchActionButton.style.border = "1px solid #8d8e8f";
      searchActionButton.style.color = "#ffffff";
      searchActionButton.style.fontSize = "13px";
      searchActionButton.style.lineHeight = "28px";
      searchActionButton.style.fontWeight = "bold";
      searchActionButton.style.textDecoration = "none";
      searchActionButton.style.webkitFontSmoothing = "antialiased";
      searchActionButton.style.whiteSpace = "nowrap";
      searchActionButton.style.textShadow = "0 0 5px rgba(255, 255, 255, 0.6)";
      searchActionButton.style.zoom = "1";
      searchActionButton.style.webkitBorderRadius = "3px";
      searchActionButton.style.backgroundColor = "#1a1a1a";
      searchActionButton.style.backgroundPosition = "center bottom";
      searchActionButton.style.backgroundSize = "100% 100%";
      searchActionButton.style.boxShadow = "inset 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 -1px 0 rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1)";
      searchActionButton.style.cursor = "pointer";
      searchActionButton.style.userSelect = "none";
      searchActionButton.style.position = "relative";
      searchActionButton.style.padding = "0 40px";
      searchActionButton.style.textAlign = "center";
      searchActionButton.style.margin = "0 10px";

      audioEntryButton.parentElement.appendChild(searchActionButton);

      searchActionButton.style.position = "absolute";
      searchActionButton.style.left = "50%";
      searchActionButton.style.transform = "translateX(-50%)";

      const bottomTrayElements = iframeDocument.querySelectorAll('[class*="bottom-tray"]');
      bottomTrayElements.forEach(trayElement => {
        trayElement.style.position = 'relative';
        const buttonClone = searchActionButton.cloneNode(true);
        trayElement.appendChild(buttonClone);
        buttonClone.style.position = "absolute";
        buttonClone.style.left = "50%";
        buttonClone.style.transform = "translateX(-50%)";
      });
    }
  }
}
if (window.top === window.self) {
const buttonCheckInterval = setInterval(checkForButton, 500);
}


const observerConfig = {
    attributes: false,
    childList: true,
    subtree: true
};

const mutationCallback = function(mutations, observerInstance) {
    for (const mutation of mutations) {
        if (mutation.type === 'childList') {
            const detectedElements = document.querySelectorAll('.mark-return');
            if (detectedElements.length > 0) {
                appendSearchButton(detectedElements[0].parentNode);
            }
        }
    }
};

const appendSearchButton = function(parentContainer) {
    const existingButton = document.getElementById('uniqueSearchButtonId');
    if (existingButton) return;

    const searchActionButton = document.createElement('button');
    searchActionButton.innerText = "Search question";
    searchActionButton.id = "uniqueSearchButtonId";

    searchActionButton.style.webkitTextSizeAdjust = "100%";
    searchActionButton.style.borderSpacing = "0";
    searchActionButton.style.borderCollapse = "collapse";
    searchActionButton.style.fontFamily = '"Helvetica Neue", Helvetica, Arial, sans-serif';
    searchActionButton.style.display = "inline-block";
    searchActionButton.style.boxSizing = "border-box";
    searchActionButton.style.height = "28px";
    searchActionButton.style.border = "1px solid #8d8e8f";
    searchActionButton.style.color = "#ffffff";
    searchActionButton.style.fontSize = "13px";
    searchActionButton.style.lineHeight = "28px";
    searchActionButton.style.fontWeight = "bold";
    searchActionButton.style.textDecoration = "none";
    searchActionButton.style.webkitFontSmoothing = "antialiased";
    searchActionButton.style.whiteSpace = "nowrap";
    searchActionButton.style.textShadow = "0 0 5px rgba(255, 255, 255, 0.6)";
    searchActionButton.style.zoom = "1";
    searchActionButton.style.webkitBorderRadius = "3px";
    searchActionButton.style.backgroundColor = "#1a1a1a";
    searchActionButton.style.backgroundPosition = "center bottom";
    searchActionButton.style.backgroundSize = "100% 100%";
    searchActionButton.style.boxShadow = "inset 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 -1px 0 rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1)";
    searchActionButton.style.cursor = "pointer";
    searchActionButton.style.userSelect = "none";

    searchActionButton.style.position = "absolute";
    searchActionButton.style.left = "35%";
    searchActionButton.style.top = "50%";
    searchActionButton.style.transform = "translate(-70%, -50%)";

    parentContainer.style.position = "relative";
    parentContainer.appendChild(searchActionButton);
};

const targetElement = document.body;

const observerInstance = new MutationObserver(mutationCallback);

observerInstance.observe(targetElement, observerConfig);

(function() {
    function checkAndAddListener() {
        const frame = window.frames[0];

        if (frame && frame.document) {
            const button = frame.document.getElementById("searchActionButton");

            if (button) {
                if (!button.dataset.listenerAdded) {
                    button.addEventListener('click', handleAssignment);
                    button.dataset.listenerAdded = true;
                    console.log("Listener added to the button within the iframe.");
                }
            }
        }
    }
if (window.top === window.self) {
    setInterval(checkAndAddListener, 500);}

})();

if (window.top === window.self) {
function monitorFrameForButton() {
    const frame = window.frames[0];

    const checkInterval = setInterval(() => {
        if (frame && frame.document) {
            const button = frame.document.getElementById('uniqueSearchButtonId');
            if (button) {
                if (!frame.hasListenerAdded) {
                    button.addEventListener('click', handleAssessment);
                    frame.hasListenerAdded = true;
                    console.log('Listener added to the button.');

                    clearInterval(checkInterval);
                }
            }
        }
    }, 100);
}

monitorFrameForButton();
}


let buttonsClicked = false;

function updateTextareaAndClickButtonsOnce() {
    try {
        const iframeDoc = window.frames[0].frames[0].document;

        if (iframeDoc.readyState === 'complete') {
            const textarea = iframeDoc.querySelector('.QuestionTextArea');

            if (textarea && textarea.value.trim() === '') {
                const answerChoices = iframeDoc.querySelectorAll('.answer-choice-label');

                let allText = '';

                answerChoices.forEach(choice => {
                    allText += choice.textContent.trim() + '\n';
                });

                textarea.value = allText.trim();

                const buttons = iframeDoc.querySelectorAll('.answer-choice-button');

                buttons.forEach(button => {
                    if (button) {
                        button.click();
                    } else {
                        console.warn("Button with class 'answer-choice-button' not found.");
                    }
                });

                const doneButtons = iframeDoc.querySelectorAll('.done-start');
                setTimeout(() => {
                    doneButtons.forEach(doneButton => {
                        if (doneButton) {
                            doneButton.click();
                        } else {
                            console.warn("Button with class 'done-start' not found.");
                        }
                    });

                    const retryButtons = iframeDoc.querySelectorAll('.done-retry');
                    setTimeout(() => {
                        retryButtons.forEach(retryButton => {
                            if (retryButton) {
                                retryButton.click();
                            } else {
                                console.warn("Button with class 'done-retry' not found.");
                            }
                        });
                    },400);
                }, 200);
            }
        }
    } catch (error) {
        console.error("An error occurred:", error);
    }
}
function checkUpdateTextareaAndClickButtonsOnce() {
    const isAutoWritingChecked = document.getElementById('autoWritingCheckbox').checked;
    const element = document.getElementById('activity-title');

    const isAssignmentTitle = element && element.textContent.includes("Assignment");

    const isAutoWritingOnAssignmentChecked = isAssignmentTitle
        ? document.getElementById('autoWritingOnAssignmentCheckbox').checked
        : true;

    if (isAutoWritingChecked && (isAssignmentTitle ? isAutoWritingOnAssignmentChecked : true)) {
        updateTextareaAndClickButtonsOnce();
    }
}
if (window.top === window.self) {
setInterval(checkUpdateTextareaAndClickButtonsOnce, 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) {}
        }
    }
}

function checkcheckOpacity() {
    const isGuessingChecked = document.getElementById('guessingCheckbox').checked;
    if (isGuessingChecked) {
        checkOpacity();
    }
}
if (window.top === window.self) {
setInterval(checkcheckOpacity, 1000);}



setInterval(function() {
    var element = document.getElementById("invis-o-div");
    if (element) {
        element.remove();
    }
}, 1000);



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

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



var clipboardButton;

function createClipboardSearchButton() {
    try {
        var iframe = document.querySelector("iframe");
        if (iframe) {
            var rect = iframe.getBoundingClientRect();
            var iframeTop = rect.top + window.scrollY;
            var iframeRight = rect.right + window.scrollX;

            var buttonContainer = document.createElement('div');
            buttonContainer.style.position = 'fixed';
            buttonContainer.style.top = (iframeTop + 10) + 'px';
            buttonContainer.style.left = (iframeRight - 150) + 'px';
            buttonContainer.style.zIndex = '9999';
            document.body.appendChild(buttonContainer);

            clipboardButton = document.createElement('button');
            clipboardButton.innerText = 'Search Clipboard';
            buttonContainer.appendChild(clipboardButton);
        }
    } catch (error) {
        console.error('Error accessing the first iframe:', error);
    }
}

function checkClipboardSearchButton() {
    const isClipboardChecked = document.getElementById('searchClipboardCheckbox').checked;

    if (isClipboardChecked) {
        if (!clipboardButton) {
            createClipboardSearchButton();
        }
    } else {
        if (clipboardButton) {
            clipboardButton.parentElement.removeChild(clipboardButton);
            clipboardButton = null;
        }
    }
}
if (window.top === window.self) {
setInterval(checkClipboardSearchButton, 1000);}


document.addEventListener('click', function(event) {
    if (event.target.tagName === 'BUTTON' && event.target.innerText.includes('Clipboard')) {
        navigator.clipboard.readText().then(function(clipboardText) {
            if (clipboardText) {
                var isBrainlyChecked = document.getElementById('searchInBrainlyCheckbox').checked;
                var searchUrl = 'https://brainly.com/app/ask?entry=top&q=' + encodeURIComponent(clipboardText);

                if (isBrainlyChecked) {
                    var brainlyIframe = document.getElementById('brainly-chat-iframe');
                    if (brainlyIframe) {
                        brainlyIframe.src = searchUrl;
                    }
                } else {
                    window.open(searchUrl, '_blank');
                }
            }
        }).catch(function(err) {
            console.error('Failed to read clipboard contents: ', err);
        });
    }
});

function addDeepaiIframes() {
    const wrapElement = document.getElementById('wrap');

    if (!document.getElementById('deepai-chat-iframe')) {
        const deepaiIframe = document.createElement('iframe');
        deepaiIframe.id = 'deepai-chat-iframe';
        deepaiIframe.src = 'https://deepai.org/chat';

        deepaiIframe.style.width = '25%';
        deepaiIframe.style.height = '100vh';
        deepaiIframe.style.border = 'none';
        deepaiIframe.style.position = 'absolute';
        deepaiIframe.style.top = '0';
        deepaiIframe.style.right = '0';
        deepaiIframe.style.zIndex = '20000';
        wrapElement.style.position = 'relative';
        deepaiIframe.style.opacity = '0';
        deepaiIframe.style.transition = 'opacity 0.5s';
        deepaiIframe.sandbox = 'allow-same-origin allow-scripts';

        document.body.appendChild(deepaiIframe);
    }
}

function addBrainlyIframes() {
    const wrapElement = document.getElementById('wrap');

    if (!document.getElementById('brainly-chat-iframe')) {
        const brainlyIframe = document.createElement('iframe');
        brainlyIframe.id = 'brainly-chat-iframe';
        brainlyIframe.src = 'https://brainly.com/search';

        brainlyIframe.style.width = '25%';
        brainlyIframe.style.height = '100vh';
        brainlyIframe.style.border = 'none';
        brainlyIframe.style.position = 'absolute';
        brainlyIframe.style.top = '0';
        brainlyIframe.style.left = '0';
        brainlyIframe.style.zIndex = '20000';
        wrapElement.style.position = 'relative';
        brainlyIframe.style.opacity = '0';
        brainlyIframe.style.transition = 'opacity 0.5s';
        brainlyIframe.sandbox = 'allow-same-origin allow-scripts';

        document.body.appendChild(brainlyIframe);
    }
}

addDeepaiIframes();
addBrainlyIframes();

function updateDeepaiIframeVisibility() {
    const deepaiIframe = document.getElementById('deepai-chat-iframe');
    const isAiChatChecked = document.getElementById('aiChatCheckbox').checked;

    if (deepaiIframe) {
        if (isAiChatChecked) {
            deepaiIframe.style.opacity = '1';
            deepaiIframe.style.display = 'block';
        } else {
            deepaiIframe.style.opacity = '0';
            setTimeout(() => deepaiIframe.style.display = 'none', 500);
        }
    }
}

function updateBrainlyIframeVisibility() {
    const brainlyIframe = document.getElementById('brainly-chat-iframe');
    const isBrainlyChecked = document.getElementById('searchInBrainlyCheckbox').checked;

    if (brainlyIframe) {
        if (isBrainlyChecked) {
            brainlyIframe.style.opacity = '1';
            brainlyIframe.style.display = 'block';
        } else {
            brainlyIframe.style.opacity = '0';
            setTimeout(() => brainlyIframe.style.display = 'none', 500);
        }
    }
}

setInterval(() => {
    updateDeepaiIframeVisibility();
    updateBrainlyIframeVisibility();
}, 1000);

function createButtonAndPane() {
    if (document.querySelector('#tweaksButton')) return;

    const mainFootDiv = document.querySelector('.mainfoot');

    const toggleButton = document.createElement('button');
    toggleButton.id = 'tweaksButton';
    toggleButton.textContent = 'Toggle Options';

    toggleButton.style.border = "1px solid #5f5f5f";
    toggleButton.style.boxShadow = "inset 0 0 5px rgba(0, 0, 0, 0.6)";
    toggleButton.style.backgroundColor = "rgb(39, 39, 39)";
    toggleButton.style.color = "#f9a619";
    toggleButton.style.borderRadius = "3px";
    toggleButton.style.marginLeft = "40%";
    toggleButton.style.zIndex = "2";
    toggleButton.style.padding = '5px 10px';

    mainFootDiv.appendChild(toggleButton);

    if (!window.pane) {
        window.pane = document.createElement('div');
        window.pane.style.display = 'none';
        document.body.appendChild(window.pane);

        const popupMenu = document.createElement('div');
        popupMenu.className = 'popup-menu';

        const aiChatItem = createMenuItem('AI Chat', 'aiChatCheckbox');
        popupMenu.appendChild(aiChatItem);

        const searchInBrainlyItem = createMenuItem('Search in Brainly frame', 'searchInBrainlyCheckbox');
        popupMenu.appendChild(searchInBrainlyItem);

        const autoVocabItem = createMenuItem('Auto Vocab', 'autoVocabCheckbox');
        popupMenu.appendChild(autoVocabItem);

        const autoWritingItem = createMenuItem('Auto Writing', 'autoWritingCheckbox');
        popupMenu.appendChild(autoWritingItem);

        const autoplayItem = createMenuItem('Autoplay', 'autoplayCheckbox');
        popupMenu.appendChild(autoplayItem);

        const searchClipboardItem = createMenuItem('Search Clipboard Button', 'searchClipboardCheckbox');
        popupMenu.appendChild(searchClipboardItem);

        const guessingItem = createMenuItem('Guessing', 'guessingCheckbox');
        popupMenu.appendChild(guessingItem);

        const autoWritingOnAssignmentItem = createMenuItem('AutoWriting On Assignment', 'autoWritingOnAssignmentCheckbox');
        popupMenu.appendChild(autoWritingOnAssignmentItem);

        window.pane.appendChild(popupMenu);

const footerText = document.createElement('div');
footerText.style.marginTop = '20px';
footerText.style.color = 'rgb(249, 166, 25)';
footerText.style.textAlign = "center";
footerText.textContent = "This was made by me, TallTacoTristan, as a way to make edge-nuity " +
    "classes MUCH easier and skip by the tedious bits but it took a long time, probably over " +
    "24 hours of just coding, to write over half a thousand lines, it has many features, " +
    "the ones above are less than half, just the ones that need a toggle. " +
    "So please leave a good review on my page for all the time I spent to save yours, Thank you.";

const discordMessage = document.createElement('div');
discordMessage.textContent = "Join this discord if you have any issues, questions, or suggestions!.";
discordMessage.style.marginTop = '10px';

const discordLink = document.createElement('a');
discordLink.textContent = "https://discord.gg/6qJwkYSmrQ";
discordLink.href = "https://discord.gg/6qJwkYSmrQ";
discordLink.target = "_blank";
discordLink.style.marginTop = '5px';
discordLink.style.color = 'cyan';
discordLink.style.textDecoration = 'underline';

footerText.appendChild(discordMessage);
footerText.appendChild(discordLink);

window.pane.appendChild(footerText);


        loadCheckboxState('aiChat', 'aiChatCheckbox');
        loadCheckboxState('searchInBrainly', 'searchInBrainlyCheckbox');
        loadCheckboxState('autoVocab', 'autoVocabCheckbox');
        loadCheckboxState('autoWriting', 'autoWritingCheckbox');
        loadCheckboxState('autoplay', 'autoplayCheckbox');
        loadCheckboxState('searchClipboard', 'searchClipboardCheckbox');
        loadCheckboxState('guessing', 'guessingCheckbox');
        loadCheckboxState('autoWritingOnAssignment', 'autoWritingOnAssignmentCheckbox');

        makeDraggable(window.pane);
    }

    toggleButton.addEventListener('click', function() {
        console.log('Button clicked! Toggling pane visibility.');

        if (window.pane.style.display === 'none' || window.pane.style.display === '') {
            window.pane.style.width = "50%";
            window.pane.style.height = "auto";
            window.pane.style.position = "absolute";
            window.pane.style.marginTop = "20vh";
            window.pane.style.marginLeft = "25%";
            window.pane.style.border = "1px solid rgb(95, 95, 95)";
            window.pane.style.borderRadius = "3px";
            window.pane.style.backgroundColor = "rgb(39, 39, 39)";
            window.pane.style.overflow = "hidden";
            window.pane.style.color = "rgb(249, 166, 25)";
            window.pane.style.textAlign = "center";
            window.pane.style.overflowY = "scroll";
            window.pane.style.display = 'block';

            checkCheckboxState('aiChatCheckbox');
            checkCheckboxState('searchInBrainlyCheckbox');
            checkCheckboxState('autoVocabCheckbox');
            checkCheckboxState('autoWritingCheckbox');
            checkCheckboxState('autoplayCheckbox');
            checkCheckboxState('searchClipboardCheckbox');
            checkCheckboxState('guessingCheckbox');
            checkCheckboxState('autoWritingOnAssignmentCheckbox');
        } else {
            window.pane.style.display = 'none';
        }
    });
}
function makeDraggable(element) {
    let offsetX, offsetY;

    element.addEventListener('mousedown', function(e) {
        e.preventDefault();
        offsetX = e.clientX - element.getBoundingClientRect().left + element.offsetWidth / 2;
        offsetY = e.clientY - element.getBoundingClientRect().top + element.offsetHeight / 2;
        element.classList.add('dragging');

        document.addEventListener('mousemove', dragElement);
        document.addEventListener('mouseup', stopDragging);
    });

    function dragElement(e) {
        e.preventDefault();
        let x = e.clientX - offsetX;
        let y = e.clientY - offsetY;

        element.style.left = x + 'px';
        element.style.top = y + 'px';
    }

    function stopDragging() {
        element.classList.remove('dragging');
        document.removeEventListener('mousemove', dragElement);
        document.removeEventListener('mouseup', stopDragging);
    }
}
function createMenuItem(text, checkboxId) {
    const itemDiv = document.createElement('div');
    itemDiv.className = 'menu-item';

    const checkbox = document.createElement('input');
    checkbox.type = 'checkbox';
    checkbox.id = checkboxId;

    const storedValue = localStorage.getItem(checkboxId);
    if (storedValue !== null) {
        checkbox.checked = (storedValue === 'true');
    }

    const label = document.createElement('label');
    label.innerText = text;
    label.setAttribute('for', checkboxId);

    itemDiv.appendChild(checkbox);
    itemDiv.appendChild(label);

    checkbox.addEventListener('change', () => {
        console.log(`${text} checkbox is now ${checkbox.checked ? 'checked' : 'unchecked'}`);
        localStorage.setItem(checkboxId, checkbox.checked);
    });

    return itemDiv;
}

function loadCheckboxState(checkboxId) {
    const storedValue = localStorage.getItem(checkboxId);
    if (storedValue !== null) {
        const checkbox = document.getElementById(checkboxId);
        if (checkbox) {
            checkbox.checked = (storedValue === 'true');
        }
    }
}

function checkCheckboxState(checkboxId) {
    const checkbox = document.getElementById(checkboxId);
    const storedValue = localStorage.getItem(checkboxId);

    if (storedValue !== null && checkbox) {
        if (checkbox.checked !== (storedValue === 'true')) {
            checkbox.checked = (storedValue === 'true');
        }
    }
}
if (window.top === window.self) {
setInterval(createButtonAndPane, 1000);}



var checkbox = document.getElementById('searchInBrainlyCheckbox');





let lastTitle = '';

function checkForAssignment() {
    const element = document.getElementById('activity-title');
    if (element) {
        const currentTitle = element.textContent || element.innerText;

        const excludedKeywords = [
            "Summary", "Warm-Up", "Instruction", "Quiz",
            "Assignment", "Unit Test",
            "Unit Review", "Cumulative Exam Review",
            "Vocab","Cumulative Exam"
        ];

        const containsExcludedKeyword = excludedKeywords.some(keyword => currentTitle.includes(keyword));
        const currentContainsAssignment = currentTitle.includes("Assignment");

        if (currentTitle !== lastTitle) {
            if (currentContainsAssignment || !containsExcludedKeyword) {
                new Notification("Done!");
            }
            lastTitle = currentTitle;
        }
    }
}if (window.top === window.self) {
setInterval(checkForAssignment, 1000);}

const isAutoVocabChecked = document.getElementById('autoVocabCheckbox').checked;


function clickNextButtonIfVocabulary() {
    if (document.getElementById("activity-title").innerText === "Vocabulary") {
        const nextButton = window.frames[0].document.getElementsByClassName("uibtn uibtn-blue uibtn-arrow-next")[0];
        if (nextButton) {
            nextButton.click();
            console.log("Clicked next button");
        } else {
            console.log("Next button not found");
        }
    }
}

function vocabCompleter() {
    if (document.getElementById("activity-title").innerText === "Vocabulary") {
        var i = 0;
        try {
            var txt = window.frames[0].document.getElementsByClassName("word-background")[0].value;
            window.frames[0].document.getElementsByClassName("word-textbox")[0].value = txt;
            var event = new Event("keyup");
            window.frames[0].document.getElementsByClassName("word-textbox word-normal")[0].dispatchEvent(event);
        } catch (e) {
            console.error(e);
            return;
        }

        var speed = 50;
        var output = "Vocab Completer, ";

        window.frames[0].document.getElementsByClassName("playbutton vocab-play")[0].click();
        window.frames[0].document.getElementsByClassName("playbutton vocab-play")[1].click();

    }
}

function checkAndExecuteFunctions() {
    const isAutoVocabChecked = document.getElementById('autoVocabCheckbox').checked;
    if (isAutoVocabChecked) {
        clickNextButtonIfVocabulary();
        vocabCompleter();
    }
}
if (window.top === window.self) {
setInterval(checkAndExecuteFunctions, 1000);}


if (window.top === window.self) {
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);}