// ==UserScript==
// @name Edge-nuity Megascript
// @version 1.5
// @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 *://*core.learn*/*
// @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);
}
};
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 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();
}
}
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) {}
}
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();
}
}
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]+|<[^>]*>| | /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 (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();
}
}
});
console.log('Key listener added to frame.');
}
}
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();
}
}
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();
}
}
setInterval(checkcheckOpacity, 1000);
setInterval(function() {
document.getElementById("invis-o-div").remove();
}, 1000);
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);
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;
}
}
}
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');
}
}
}
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;
}
}
}
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();
}
}
setInterval(checkAndExecuteFunctions, 1000);
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);