Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open your userscript managers dashboard to see the scripts you have, and edit the edgenuity megascript, click ctrl+a then paste this to replace the current script:
- (for example, this is my link for tampermonkey: chrome-extension://dhdgffkkebhmkfjojejmpbldmpobfkfo/options.html#url=&nav=dashboard )
- // ==UserScript==
- // @name Edge-nuity Megascript
- // @version 0.6
- // @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/
- // @downloadURL https://update.greasyfork.org/scripts/515137/Edge-nuity%20Megascript.user.js
- // @updateURL https://update.greasyfork.org/scripts/515137/Edge-nuity%20Megascript.meta.js
- // ==/UserScript==
- (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 extractTextFromIframe() {
- try {
- // Access the content of the iframe
- var iframeDocument = window.frames[0].document;
- // Get all elements with the specified class
- var targetElements = iframeDocument.getElementsByClassName("Assessment_Main_Body_Content_Question");
- // Filter elements that are visible and have 'q_' in their id
- var visibleElements = Array.from(targetElements).filter(function(element) {
- return element.style.display !== "none" && element.id.includes("q_");
- });
- if (visibleElements.length > 0) {
- var finalTextOutput = [];
- // Regex to extract visible text between tags, excluding unwanted attributes
- var regex = />([^<]+)</g; // For extracting text between > and <
- var regexSpecial = /»([^«]+)«/g; // For extracting text between » and «
- var regexCleanUp = /[\n\r]+|<[^>]*>| /g; // To clean up any unnecessary breaks, tags, and
- // Loop through all visible elements to extract text and alt attributes
- visibleElements.forEach(function(targetElement) {
- var elementText = "";
- // Loop through matches for standard HTML content extraction
- let matches;
- while ((matches = regex.exec(targetElement.innerHTML)) !== null) {
- var extractedText = matches[1].trim(); // Extract the matched text
- if (extractedText && !/(class|src|align|style)=/i.test(extractedText)) {
- elementText += extractedText + " "; // Collect cleaned text
- }
- }
- // Loop through matches for the » and « content extraction
- while ((matches = regexSpecial.exec(targetElement.innerHTML)) !== null) {
- var extractedText = matches[1].trim(); // Extract the matched text
- if (extractedText && !/(class|src|align|style)=/i.test(extractedText)) {
- elementText += extractedText + " "; // Collect cleaned text
- }
- }
- // Extract alt attributes from any img elements
- var imgElements = targetElement.getElementsByTagName("img");
- Array.from(imgElements).forEach(function(img) {
- if (img.alt) {
- elementText += img.alt.trim() + " "; // Append alt text if it exists
- }
- });
- // Clean the text further to remove any HTML/whitespace artifacts
- elementText = elementText.replace(regexCleanUp, ' ').trim();
- // Ensure non-breaking spaces are replaced with a normal space
- elementText = elementText.replace(/ /g, ' '); // Removing
- // If there's valid text, push to output array
- if (elementText) {
- finalTextOutput.push(elementText);
- }
- });
- // Create a temporary textarea to hold the extracted text
- var tempTextArea = document.createElement("textarea");
- // Join extracted texts for final output
- tempTextArea.value = finalTextOutput.join("\n").replace(/\s+/g, ' '); // Cleanup spaces
- document.body.appendChild(tempTextArea);
- // Select the content and copy it to clipboard
- tempTextArea.select();
- document.execCommand("Copy");
- // Remove the temporary element from the DOM
- document.body.removeChild(tempTextArea);
- // Find the button and click it after a delay
- setTimeout(function() {
- var buttons = Array.from(document.getElementsByTagName('button'));
- var searchClipboardButton = buttons.find(button => button.innerText === "Search Clipboard");
- if (searchClipboardButton) {
- searchClipboardButton.click(); // Click the button if found
- }
- }, 101); // 101 milliseconds delay (0.1 seconds)
- } else {
- console.log("No visible elements with 'q_' in the ID found in iframe");
- }
- } catch (typeError) {
- console.error("An error occurred: " + typeError.message);
- }
- }
- document.addEventListener('keydown', function(event) {
- // Check if the key pressed is "3"
- if (event.key === '3') {
- setTimeout(() => {
- extractTextFromIframe();
- }, 250); // Delay of 2000 milliseconds (2 seconds)
- // Access the iframe content - assuming it's the first iframe
- const iframe = window.frames[0];
- const iframeDocument = iframe.document;
- // Get all elements with the specified class
- const targetElements = iframeDocument.getElementsByClassName("Assessment_Main_Body_Content_Question");
- // Filter elements that are visible and have 'q_' in their id
- const visibleElements = Array.from(targetElements).filter(function(element) {
- return element.style.display !== "none" && element.id.includes("q_");
- });
- let result = [];
- // Loop through the visible elements to extract text and alt attributes from answer-choice-labels
- for (let i = 0; i < visibleElements.length; i++) {
- // Handle answer-choice-labels
- const labels = visibleElements[i].getElementsByClassName("answer-choice-label");
- for (let j = 0; j < labels.length; j++) {
- let labelText = labels[j].textContent.trim();
- // Check for child image elements and add their alt attributes if present
- const images = labels[j].getElementsByTagName('img');
- for (let k = 0; k < images.length; k++) {
- const altText = images[k].getAttribute('alt');
- if (altText) {
- labelText += ` ${altText}`; // Append alt text to the label text
- }
- }
- if (labelText) {
- result.push(labelText); // Store the final text including alt text
- }
- }
- // Handle centered-text elements
- const centeredElements = visibleElements[i].getElementsByClassName("centered-text");
- for (let j = 0; j < centeredElements.length; j++) {
- let centeredText = centeredElements[j].textContent.trim();
- // Check for child image elements and add their alt attributes if present
- const images = centeredElements[j].getElementsByTagName('img');
- for (let k = 0; k < images.length; k++) {
- const altText = images[k].getAttribute('alt');
- if (altText) {
- centeredText += ` ${altText}`; // Append alt text to the centered text
- }
- }
- if (centeredText) {
- result.push(centeredText); // Store the centered text including alt text
- }
- }
- }
- // Create a new div to display the extracted texts
- let resultsContainer = document.getElementById('results-container');
- // If the results container already exists, remove it
- if (resultsContainer) {
- resultsContainer.remove();
- }
- // Create a new results container
- resultsContainer = document.createElement('div');
- resultsContainer.id = 'results-container';
- resultsContainer.style.position = 'fixed'; // Fixed position on top
- resultsContainer.style.top = '10px'; // Slight space from the top
- resultsContainer.style.left = '10px'; // Slight space from the left
- resultsContainer.style.backgroundColor = 'white'; // Background color
- resultsContainer.style.border = '1px solid black'; // Border for visibility
- resultsContainer.style.padding = '10px';
- resultsContainer.style.zIndex = '1000'; // Ensure it appears on top
- document.body.appendChild(resultsContainer); // Append to the body
- // Append extracted texts to the results container
- result.forEach((text) => {
- const entry = document.createElement('div');
- entry.textContent = text;
- resultsContainer.appendChild(entry); // Add each result to the results container
- });
- }
- });
- document.addEventListener('keydown', function(event) {
- if (event.ctrlKey && event.altKey && event.key === 'c') {
- try {
- const nestedIframeDocument = window.frames[0].frames[0].document;
- const contentElements = nestedIframeDocument.getElementsByClassName("content");
- const altElements = nestedIframeDocument.querySelectorAll('[alt]'); // Select all elements with an "alt" attribute
- let contentText = '';
- // Process content elements
- if (contentElements.length > 0) {
- contentText = Array.from(contentElements)
- .map(element => element.innerText)
- .join('\n');
- } else {
- console.error('No elements with class="content" found.');
- }
- // Process alt elements
- const altValues = Array.from(altElements)
- .map(element => element.getAttribute('alt')) // Get the alt attribute values
- .join('\n'); // Join them into a single string
- // Combine content text and alt values
- const combinedText = contentText + (contentText && altValues ? '\n' : '') + altValues;
- // Check if we have content to copy
- if (combinedText) {
- navigator.clipboard.writeText(combinedText)
- .then(() => {
- console.log('Content copied to clipboard!');
- })
- .catch(err => {
- console.error('Failed to copy content to clipboard:', err);
- });
- } else {
- console.error('No content to copy.');
- }
- } catch (TypeError) {
- console.error("Error accessing nested iframe or elements. Check the frame structure.");
- }
- }
- });
- // Check for Ctrl + Alt + V
- document.addEventListener('keydown', function(event) {
- if ((event.ctrlKey || event.metaKey) && event.altKey && event.key === 'v') {
- event.preventDefault();
- const buttons = Array.from(document.querySelectorAll('button'));
- const buttonToClick = buttons.find(button => button.innerText === 'Search Clipboard');
- if (buttonToClick) {
- buttonToClick.click();
- } else {
- console.log('Button with the inner text "Search Clipboard" not found.');
- }
- }
- });
- 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');
- // Check if the element exists and contains the text "Assignment"
- const isAssignmentTitle = element && element.textContent.includes("Assignment");
- // If it's an assignment, check the assignment specific checkbox
- const isAutoWritingOnAssignmentChecked = isAssignmentTitle
- ? document.getElementById('autoWritingOnAssignmentCheckbox').checked
- : true; // Default to true if not an assignment
- // Call updateTextareaAndClickButtonsOnce only if the correct checkboxes are checked
- if (isAutoWritingChecked && (isAssignmentTitle ? isAutoWritingOnAssignmentChecked : true)) {
- updateTextareaAndClickButtonsOnce();
- }
- }
- // Run the check every second
- 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 {
- const iframe = document.querySelector("iframe");
- if (iframe) {
- const rect = iframe.getBoundingClientRect();
- const iframeTop = rect.top + window.scrollY;
- const iframeRight = rect.right + window.scrollX;
- const 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);
- // Update URL when the clipboard changes
- setInterval(updateClipboardUrl, 100);
- clipboardButton.onclick = function(event) {
- event.stopPropagation();
- const searchUrl = clipboardButton.getAttribute('data-url');
- if (searchUrl) {
- const isBrainlyChecked = document.getElementById('searchInBrainlyCheckbox').checked;
- if (isBrainlyChecked) {
- const brainlyIframe = document.getElementById('brainly-chat-iframe');
- if (brainlyIframe) {
- brainlyIframe.src = searchUrl;
- } else {
- console.error('Brainly iframe not found.');
- }
- } else {
- window.open(searchUrl, '_blank');
- }
- }
- };
- }
- } catch (error) {
- console.error('Error accessing the first iframe:', error);
- }
- }
- function updateClipboardUrl() {
- navigator.clipboard.readText().then(function(clipboardText) {
- if (clipboardText) {
- const searchUrl = 'https://brainly.com/app/ask?entry=top&q=' + encodeURIComponent(clipboardText);
- clipboardButton.setAttribute('data-url', searchUrl);
- }
- }).catch(function(err) {
- console.error('Could not read clipboard text: ', err);
- });
- }
- 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);
- 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';
- // Apply styles to the button
- 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.";
- 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');
- // Make the pane draggable
- 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;
- offsetY = e.clientY - element.getBoundingClientRect().top;
- element.classList.add('dragging');
- document.addEventListener('mousemove', dragElement);
- document.addEventListener('mouseup', stopDragging);
- });
- function dragElement(e) {
- e.preventDefault();
- // Adjust x and y position based on offset with an additional offset for the Northwest position
- let x = e.clientX - offsetX - (element.offsetWidth * 0.2); // 20% to the left
- let y = e.clientY - offsetY - (element.offsetHeight * 0.9); // 20% up
- // Set the new position of the element
- 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 vocabCompleter() {
- if (isAutoVocabChecked) {
- if (document.getElementById("activity-title").innerText == "Vocabulary") {
- try {
- window.frames[0].document.getElementsByClassName("word-textbox")[0].value =
- window.frames[0].document.getElementsByClassName("word-background")[0].value;
- } catch (TypeError) {}
- try {
- for (var x of window.frames[0].document.getElementsByClassName("playbutton vocab-play")) {
- x.click();
- }
- } catch (TypeError) {}
- try {
- window.frames[0].document.getElementsByClassName("uibtn uibtn-blue uibtn-arrow-next")[0].click();
- } catch (TypeError) {}
- clickFootnavAndNextFrame();
- }
- }
- }
- setInterval(vocabCompleter, 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);
- let successCount = 0;
- const requiredSuccesses = 600;
- const checkInterval = 1000;
- const checkCondition = () => {
- if (frames[0] && frames[0].document) {
- const homeVideoContainer = frames[0].document.getElementById("home_video_container");
- if (homeVideoContainer && homeVideoContainer.parentNode.style.opacity == 1) {
- successCount++;
- if (successCount >= requiredSuccesses) {
- new Notification("Reload Page!");
- successCount = 0;
- }
- } else {
- successCount = 0;
- }
- } else {
- successCount = 0;
- }
- };
- const intervalId = setInterval(checkCondition, checkInterval);
- (function() {
- 'use strict';
- // Get the current URL and previous URL from GM_value
- const currentUrl = window.location.href;
- const previousUrl = GM_getValue("previousHref");
- // If the current URL is Brainly
- if (currentUrl.includes("brainly")) {
- // Check if the previous URL does not match the current URL
- if (previousUrl !== currentUrl) {
- // Prompt the user for a number
- const userInput = prompt("Please enter a number:");
- // Check if the input is a valid number
- if (!isNaN(userInput) && userInput !== null) {
- // Store the input value
- GM_setValue("numberFromBrainly", userInput);
- }
- }
- }
- // Function to check for changes and alert the number if it exists
- function checkForNumber() {
- // Retrieve the stored number value
- const storedNumber = GM_getValue("numberFromBrainly");
- // Alert the number if it exists
- if (storedNumber) {
- alert("The number you entered on Brainly is: " + storedNumber);
- // Clear the stored value after alerting
- GM_setValue("numberFromBrainly", null);
- }
- }
- // If the current URL is Google, set an interval to check for the number
- if (currentUrl.includes("google")) {
- setInterval(checkForNumber, 1000); // Check every second (1000 milliseconds)
- }
- // Store the current URL as the previous URL for future comparisons
- GM_setValue("previousHref", currentUrl);
- })();
- click ctrl+s to make sure the change is saved then you can close the tab
- then click the "+" or "create a new script" from the extension dropdown (pin the extension, then click the icon) or the "+" from the dashboard page
- click ctrl+a then ctrl+v to make this the new script:
- // ==UserScript==
- // @name Open the show clipboard button in background tab
- // @author TTT
- // @description Open the show clipboard button in background tab
- // @grant GM_openInTab
- // @include *://*core.learn*/*
- // @run-at document-start
- // @version 1.0
- // @require https://greasyfork.org/scripts/12228/code/setMutationHandler.js
- // ==/UserScript==
- attachHandler([].slice.call(document.getElementsByTagName('a')));
- attachButtonHandler([].slice.call(document.getElementsByTagName('button')));
- setMutationHandler(document, 'button', function(nodes) {
- attachButtonHandler(nodes);
- return true;
- });
- function attachHandler(nodes) {
- nodes.forEach(function(node) {
- if (node.target !== '_blank') {
- node.onclick = clickHandler;
- node.addEventListener('click', clickHandler);
- }
- });
- }
- function attachButtonHandler(buttons) {
- buttons.forEach(function(button) {
- button.onclick = buttonClickHandler;
- button.addEventListener('click', buttonClickHandler);
- });
- }
- function clickHandler(e) {
- const href = this.href;
- if (href.includes('brainly.com')) {
- if (e.button > 1) return;
- e.preventDefault();
- e.stopPropagation();
- e.stopImmediatePropagation();
- GM_openInTab(href, true);
- }
- }
- function buttonClickHandler(e) {
- const url = this.getAttribute('data-url');
- if (url && url.includes('brainly.com')) {
- if (e.button > 1) return;
- e.preventDefault();
- e.stopPropagation();
- e.stopImmediatePropagation();
- GM_openInTab(url, true);
- }
- }
- make sure to also save this by ctrl+s
- Then lastly, make this a new script as well by doing the same things
- // ==UserScript==
- // @name Match options to brainly
- // @namespace http://tampermonkey.net/
- // @version 2024-11-24
- // @description try to take over the world!
- // @author You
- // @match https://brainly.com/*
- // @include *://*core.learn*/*
- // @icon https://www.google.com/s2/favicons?sz=64&domain=brainly.com
- // @grant GM_setValue
- // @grant GM_getValue
- // ==/UserScript==
- (function() {
- 'use strict';
- let lastUrl = ""; // Store the last known URL
- let lastStoredValue = null;
- // Function to get the text from the results container
- function getResultsContainerTexts() {
- const resultsContainer = document.getElementById('results-container');
- const childrenTexts = Array.from(resultsContainer.children).map(child => child.innerText.trim());
- return childrenTexts;
- }
- // Function to continuously check and update GM values
- function updateGMValues() {
- const texts = getResultsContainerTexts();
- // Update GM values for each child
- texts.forEach((text, index) => {
- GM_setValue(`childText${index + 1}`, text); // Store text for child 1, 2, 3, 4
- });
- }
- // Function to check for direct matches with GM values (returns last match)
- function checkDirectMatches(textContents) {
- let lastMatch = null; // Variable to keep track of the last match
- for (let i = 1; i <= 4; i++) {
- const childValue = GM_getValue(`childText${i}`);
- for (const line of textContents) {
- if (line.includes(childValue)) {
- lastMatch = { match: childValue, childIndex: i }; // Update last match found
- }
- }
- }
- // If a last match was found, update the GM value
- if (lastMatch) {
- const sanitizedValue = String.fromCharCode(64 + lastMatch.childIndex); // Convert index to letter A-D
- GM_setValue("numberFromBrainly", sanitizedValue);
- console.log("Last direct match found, value set for numberFromBrainly:", sanitizedValue);
- return true; // Indicate a match was found
- }
- return false; // Indicate no matches found
- }
- // Function to check regex matches if no direct matches are found
- function checkRegexMatches(textContents) {
- const digitToLetterMap = {
- '1': 'A',
- '2': 'B',
- '3': 'C',
- '4': 'D'
- };
- const keywordToLetterMap = {
- 'first': 'A',
- 'second': 'B',
- 'third': 'C',
- 'fourth': 'D',
- 'option one': 'A',
- 'option two': 'B',
- 'option three': 'C',
- 'option four': 'D'
- };
- // Updated regex patterns
- const patterns = [
- /(?<!\w)([Aa][.)])/i,
- /(?<!\w)([Bb][.)])/i,
- /(?<!\w)([Cc][.)])/i,
- /(?<!\w)([Dd][.)])/i,
- /\boption\s*\(\s*([a-dA-D1-4])\s*\)/i,
- /\boption\s*([a-dA-D1-4])\b/i,
- /\(\s*([a-dA-D1-4])\s*\)/,
- /(?:^|\s)([1-4])(?:\s|$)/,
- /\b(first|second|third|fourth)\b/i,
- /\b(option one|option two|option three|option four)\b/i
- ];
- let validOption = null;
- // Check each text content for regex matches
- for (const line of textContents) {
- for (const pattern of patterns) {
- const match = line.match(pattern);
- if (match) {
- if (digitToLetterMap[match[1]]) {
- validOption = digitToLetterMap[match[1]];
- } else if (keywordToLetterMap[match[1].toLowerCase()]) {
- validOption = keywordToLetterMap[match[1].toLowerCase()];
- } else {
- validOption = match[1].toUpperCase();
- }
- break; // Break after first valid match
- }
- }
- if (validOption) break; // Exit if a valid option is found
- }
- // If a valid option is found, set it as numberFromBrainly
- if (validOption) {
- GM_setValue("numberFromBrainly", validOption);
- console.log("Regex match found, value set for numberFromBrainly:", validOption);
- }
- return validOption; // Return the matched option for further processing
- }
- // Function to execute when the href changes
- function checkAnswerBoxes() {
- const answerBoxes = document.querySelectorAll('[data-testid="answer_box_content"]');
- const textContents = Array.from(answerBoxes).map(box => box.innerText.trim());
- const foundDirectMatch = checkDirectMatches(textContents); // Check for direct matches
- let matchedOption = null;
- // Only check regex matches if no direct matches found
- if (!foundDirectMatch) {
- matchedOption = checkRegexMatches(textContents); // Check regex matches and store matched option
- }
- replaceStoredValueAndClick(matchedOption || GM_getValue("numberFromBrainly"));
- }
- // Function to handle clicking the appropriate answer button
- function replaceStoredValueAndClick(storedNumber) {
- const activityTitleElement = document.getElementById("activity-title");
- if (activityTitleElement) {
- const activityTitleText = activityTitleElement.textContent || activityTitleElement.innerText;
- // Only proceed if in the context of "Test", "Exam", or "Quiz"
- if (activityTitleText.includes("Test") || activityTitleText.includes("Exam") || activityTitleText.includes("Quiz")) {
- const iframeDocument = window.frames[0].document;
- // Get the target elements containing the question
- const targetElements = iframeDocument.getElementsByClassName("Assessment_Main_Body_Content_Question");
- // Filter elements that are visible and have 'q_' in their id
- const visibleElements = Array.from(targetElements).filter(function(element) {
- return element.style.display !== "none" && element.id.includes("q_");
- });
- // Find visible answer buttons within these visible question elements
- const answerButtons = [];
- visibleElements.forEach(function(questionElement) {
- const buttons = questionElement.getElementsByClassName("answer-choice-button");
- answerButtons.push(...Array.from(buttons).filter(button => button.style.display !== "none"));
- });
- // Determine which button to click based on the stored number
- if (storedNumber) {
- const index = { "A": 0, "B": 1, "C": 2, "D": 3 }[storedNumber];
- if (index !== undefined && answerButtons.length > index) {
- answerButtons[index].click(); // Click the corresponding button
- } else {
- console.log("Stored number does not correspond to a valid answer button index.");
- }
- }
- }
- }
- }
- // Function to handle the URL changes
- function handleNewUrl() {
- const currentUrl = window.location.href;
- if (currentUrl.includes("brainly.com/question") && lastUrl !== currentUrl) {
- GM_setValue("numberFromBrainly", null);
- console.log("Value for numberFromBrainly set to null due to URL change:", currentUrl);
- lastUrl = currentUrl; // Update last known URL
- checkAnswerBoxes(); // There is a URL change; check the answer boxes
- }
- if (currentUrl.includes("core.learn")) {
- const storedNumber = GM_getValue("numberFromBrainly");
- if (storedNumber !== lastStoredValue) {
- lastStoredValue = storedNumber; // Update last stored value
- replaceStoredValueAndClick(storedNumber); // Attempt to click based on updated stored number
- }
- }
- }
- // Observe changes to the document's URL and changes in GM value
- const observer = new MutationObserver((mutations) => {
- if (mutations.some(mutation => mutation.type === 'childList' || mutation.type === 'attributes')) {
- handleNewUrl();
- }
- });
- // Start observing for changes in the document
- observer.observe(document.body, {
- childList: true,
- subtree: true,
- attributes: true
- });
- // Initial check when the script runs
- setInterval(updateGMValues, 100); // Update every 0.1 seconds
- checkAnswerBoxes();
- })();
- let lastValue = GM_getValue("numberFromBrainly");
- function getAnswerButtonIndex(letter) {
- switch (letter.toLowerCase().replace(/[^a-d]/g, '')) {
- case 'a':
- return 0; // First button (index 0)
- case 'b':
- return 1; // Second button (index 1)
- case 'c':
- return 2; // Third button (index 2)
- case 'd':
- return 3; // Fourth button (index 3)
- default:
- return -1; // Invalid letter
- }
- }
- function checkForChanges() {
- const currentValue = GM_getValue("numberFromBrainly");
- if (currentValue !== lastValue) {
- lastValue = currentValue; // Update last value
- // Extract the letter from the current value
- const letter = currentValue.match(/[a-dA-D][).]?/);
- if (letter) {
- const index = getAnswerButtonIndex(letter[0]);
- if (index !== -1) {
- const activityTitleElement = document.getElementById("activity-title");
- if (activityTitleElement) {
- const activityTitleText = activityTitleElement.textContent || activityTitleElement.innerText;
- // Only proceed if in the context of "Test", "Exam", or "Quiz"
- if (activityTitleText.includes("Test") || activityTitleText.includes("Exam") || activityTitleText.includes("Quiz")) {
- const iframeDocument = window.frames[0].document;
- // Get the target elements containing the question
- const targetElements = iframeDocument.getElementsByClassName("Assessment_Main_Body_Content_Question");
- // Filter elements that are visible and have 'q_' in their id
- const visibleElements = Array.from(targetElements).filter(function(element) {
- return element.style.display !== "none" && element.id.includes("q_");
- });
- // Find visible answer buttons within these visible question elements
- const answerButtons = [];
- visibleElements.forEach(function(questionElement) {
- const buttons = questionElement.getElementsByClassName("answer-choice-button");
- answerButtons.push(...Array.from(buttons).filter(button => button.style.display !== "none"));
- });
- // Click the corresponding answer button
- if (answerButtons[index]) {
- answerButtons[index].click();
- }
- }
- }
- }
- }
- }
- }
- // Start checking for changes every 100 milliseconds
- setInterval(checkForChanges, 100);
- after saving, youre done and now click "3" on your keyboard whenever you want an autoanswer search
- ALSO make sure you click outside of the test frame before clicking the key
- Enjoy:)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement