Advertisement
Guest User

Untitled

a guest
Dec 6th, 2024
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 51.35 KB | None | 0 0
  1. 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:
  2. (for example, this is my link for tampermonkey: chrome-extension://dhdgffkkebhmkfjojejmpbldmpobfkfo/options.html#url=&nav=dashboard )
  3.  
  4. // ==UserScript==
  5. // @name Edge-nuity Megascript
  6. // @version 0.6
  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).
  8. // @author TTT
  9. // @license MIT
  10. // @include *://*core.learn*/*
  11. // @include https://brainly.com/*
  12. // @grant none
  13. // @namespace https://www.tampermonkey.net/
  14. // @downloadURL https://update.greasyfork.org/scripts/515137/Edge-nuity%20Megascript.user.js
  15. // @updateURL https://update.greasyfork.org/scripts/515137/Edge-nuity%20Megascript.meta.js
  16. // ==/UserScript==
  17. (function() {
  18. 'use strict';
  19.  
  20. let completeCount = 0;
  21.  
  22. const originalConsoleLog = console.log;
  23. console.log = function() {
  24. const message = Array.from(arguments).join(' ');
  25. if (message.includes('complete')) {
  26. completeCount++;
  27. if (completeCount === 2) {
  28. const goRightButton = document.querySelector('li.FrameRight a');
  29. if (goRightButton) {
  30. goRightButton.click();
  31. completeCount = 0;
  32. }
  33. }
  34. }
  35. originalConsoleLog.apply(console, arguments);
  36. };
  37. })();
  38. function checkAutoplay() {
  39. const isAutoplayChecked = document.getElementById('autoplayCheckbox').checked;
  40. if (isAutoplayChecked) {
  41. playVideo();
  42. }
  43. }
  44.  
  45. setInterval(checkAutoplay, 1000);
  46. function playVideo() {
  47. var playButton = window.frames[0].document.getElementById("uid1_play");
  48. if (playButton != undefined) {
  49. setTimeout(function() {
  50. if (playButton.className == "play") {
  51. playButton.children[0].click();
  52. }
  53. }, 1000);
  54. }
  55. }
  56.  
  57. function showColumn() {
  58. try {
  59. window.frames[0].frames[0].document.getElementsByClassName("right-column")[0].children[0].style.display = "block";
  60. } catch (TypeError) {}
  61.  
  62. try {
  63. window.frames[0].frames[0].document.getElementsByClassName("left-column")[0].children[0].style.display = "block";
  64. } catch (TypeError) {}
  65. }
  66.  
  67. setInterval(showColumn, 1000);
  68.  
  69. function clearLocalStorage() {
  70. try {
  71. localStorage.clear();
  72. } catch (error) {}
  73. }
  74.  
  75. function removeElementsByClassName(className) {
  76. var elements = document.getElementsByClassName(className);
  77. Array.prototype.forEach.call(elements, function(element) {
  78. try {
  79. element.parentNode.removeChild(element);
  80. } catch (error) {}
  81. });
  82. }
  83.  
  84. function handleOnload() {
  85. var classNamesToRemove = [
  86. "brn-expanded-bottom-banner",
  87. "brn-brainly-plus-box",
  88. "brn-fullscreen-toplayer",
  89. "sg-overlay sg-overlay--dark"
  90. ];
  91. classNamesToRemove.forEach(function(className) {
  92. removeElementsByClassName(className);
  93. });
  94. }
  95.  
  96. if (window.location.href.includes("brainly.com")) {
  97. clearLocalStorage();
  98. handleOnload();
  99. }
  100.  
  101. function redirectToFirstSearchItem() {
  102. if (window.location.href.startsWith('https://brainly.com/app/ask')) {
  103. const searchItem = document.querySelector('[data-testid="search-item-facade-wrapper"]');
  104. if (searchItem) {
  105. const anchorElement = searchItem.querySelector('a');
  106. if (anchorElement) {
  107. const href = anchorElement.getAttribute('href');
  108. const fullUrl = `https://brainly.com${href}`;
  109. window.location.href = fullUrl;
  110. clearInterval(interval);
  111. }
  112. }
  113. }
  114. }
  115.  
  116. const interval = setInterval(redirectToFirstSearchItem, 1000);
  117.  
  118.  
  119.  
  120. function extractTextFromIframe() {
  121. try {
  122. // Access the content of the iframe
  123. var iframeDocument = window.frames[0].document;
  124.  
  125. // Get all elements with the specified class
  126. var targetElements = iframeDocument.getElementsByClassName("Assessment_Main_Body_Content_Question");
  127.  
  128. // Filter elements that are visible and have 'q_' in their id
  129. var visibleElements = Array.from(targetElements).filter(function(element) {
  130. return element.style.display !== "none" && element.id.includes("q_");
  131. });
  132.  
  133. if (visibleElements.length > 0) {
  134. var finalTextOutput = [];
  135.  
  136. // Regex to extract visible text between tags, excluding unwanted attributes
  137. var regex = />([^<]+)</g; // For extracting text between > and <
  138. var regexSpecial = /»([^«]+)«/g; // For extracting text between » and «
  139. var regexCleanUp = /[\n\r]+|<[^>]*>| /g; // To clean up any unnecessary breaks, tags, and
  140.  
  141. // Loop through all visible elements to extract text and alt attributes
  142. visibleElements.forEach(function(targetElement) {
  143. var elementText = "";
  144.  
  145. // Loop through matches for standard HTML content extraction
  146. let matches;
  147. while ((matches = regex.exec(targetElement.innerHTML)) !== null) {
  148. var extractedText = matches[1].trim(); // Extract the matched text
  149. if (extractedText && !/(class|src|align|style)=/i.test(extractedText)) {
  150. elementText += extractedText + " "; // Collect cleaned text
  151. }
  152. }
  153.  
  154. // Loop through matches for the » and « content extraction
  155. while ((matches = regexSpecial.exec(targetElement.innerHTML)) !== null) {
  156. var extractedText = matches[1].trim(); // Extract the matched text
  157. if (extractedText && !/(class|src|align|style)=/i.test(extractedText)) {
  158. elementText += extractedText + " "; // Collect cleaned text
  159. }
  160. }
  161.  
  162. // Extract alt attributes from any img elements
  163. var imgElements = targetElement.getElementsByTagName("img");
  164. Array.from(imgElements).forEach(function(img) {
  165. if (img.alt) {
  166. elementText += img.alt.trim() + " "; // Append alt text if it exists
  167. }
  168. });
  169.  
  170. // Clean the text further to remove any HTML/whitespace artifacts
  171. elementText = elementText.replace(regexCleanUp, ' ').trim();
  172.  
  173. // Ensure non-breaking spaces are replaced with a normal space
  174. elementText = elementText.replace(/ /g, ' '); // Removing
  175.  
  176. // If there's valid text, push to output array
  177. if (elementText) {
  178. finalTextOutput.push(elementText);
  179. }
  180. });
  181.  
  182. // Create a temporary textarea to hold the extracted text
  183. var tempTextArea = document.createElement("textarea");
  184. // Join extracted texts for final output
  185. tempTextArea.value = finalTextOutput.join("\n").replace(/\s+/g, ' '); // Cleanup spaces
  186.  
  187. document.body.appendChild(tempTextArea);
  188.  
  189. // Select the content and copy it to clipboard
  190. tempTextArea.select();
  191. document.execCommand("Copy");
  192.  
  193. // Remove the temporary element from the DOM
  194. document.body.removeChild(tempTextArea);
  195.  
  196. // Find the button and click it after a delay
  197. setTimeout(function() {
  198. var buttons = Array.from(document.getElementsByTagName('button'));
  199. var searchClipboardButton = buttons.find(button => button.innerText === "Search Clipboard");
  200. if (searchClipboardButton) {
  201. searchClipboardButton.click(); // Click the button if found
  202. }
  203. }, 101); // 101 milliseconds delay (0.1 seconds)
  204.  
  205. } else {
  206. console.log("No visible elements with 'q_' in the ID found in iframe");
  207. }
  208. } catch (typeError) {
  209. console.error("An error occurred: " + typeError.message);
  210. }
  211. }
  212.  
  213. document.addEventListener('keydown', function(event) {
  214. // Check if the key pressed is "3"
  215. if (event.key === '3') {
  216. setTimeout(() => {
  217.  
  218. extractTextFromIframe();
  219. }, 250); // Delay of 2000 milliseconds (2 seconds)
  220.  
  221. // Access the iframe content - assuming it's the first iframe
  222. const iframe = window.frames[0];
  223. const iframeDocument = iframe.document;
  224.  
  225. // Get all elements with the specified class
  226. const targetElements = iframeDocument.getElementsByClassName("Assessment_Main_Body_Content_Question");
  227.  
  228. // Filter elements that are visible and have 'q_' in their id
  229. const visibleElements = Array.from(targetElements).filter(function(element) {
  230. return element.style.display !== "none" && element.id.includes("q_");
  231. });
  232.  
  233. let result = [];
  234.  
  235. // Loop through the visible elements to extract text and alt attributes from answer-choice-labels
  236. for (let i = 0; i < visibleElements.length; i++) {
  237. // Handle answer-choice-labels
  238. const labels = visibleElements[i].getElementsByClassName("answer-choice-label");
  239.  
  240. for (let j = 0; j < labels.length; j++) {
  241. let labelText = labels[j].textContent.trim();
  242.  
  243. // Check for child image elements and add their alt attributes if present
  244. const images = labels[j].getElementsByTagName('img');
  245. for (let k = 0; k < images.length; k++) {
  246. const altText = images[k].getAttribute('alt');
  247. if (altText) {
  248. labelText += ` ${altText}`; // Append alt text to the label text
  249. }
  250. }
  251.  
  252. if (labelText) {
  253. result.push(labelText); // Store the final text including alt text
  254. }
  255. }
  256.  
  257. // Handle centered-text elements
  258. const centeredElements = visibleElements[i].getElementsByClassName("centered-text");
  259.  
  260. for (let j = 0; j < centeredElements.length; j++) {
  261. let centeredText = centeredElements[j].textContent.trim();
  262.  
  263. // Check for child image elements and add their alt attributes if present
  264. const images = centeredElements[j].getElementsByTagName('img');
  265. for (let k = 0; k < images.length; k++) {
  266. const altText = images[k].getAttribute('alt');
  267. if (altText) {
  268. centeredText += ` ${altText}`; // Append alt text to the centered text
  269. }
  270. }
  271.  
  272. if (centeredText) {
  273. result.push(centeredText); // Store the centered text including alt text
  274. }
  275. }
  276. }
  277.  
  278. // Create a new div to display the extracted texts
  279. let resultsContainer = document.getElementById('results-container');
  280.  
  281. // If the results container already exists, remove it
  282. if (resultsContainer) {
  283. resultsContainer.remove();
  284. }
  285.  
  286. // Create a new results container
  287. resultsContainer = document.createElement('div');
  288. resultsContainer.id = 'results-container';
  289. resultsContainer.style.position = 'fixed'; // Fixed position on top
  290. resultsContainer.style.top = '10px'; // Slight space from the top
  291. resultsContainer.style.left = '10px'; // Slight space from the left
  292. resultsContainer.style.backgroundColor = 'white'; // Background color
  293. resultsContainer.style.border = '1px solid black'; // Border for visibility
  294. resultsContainer.style.padding = '10px';
  295. resultsContainer.style.zIndex = '1000'; // Ensure it appears on top
  296. document.body.appendChild(resultsContainer); // Append to the body
  297.  
  298. // Append extracted texts to the results container
  299. result.forEach((text) => {
  300. const entry = document.createElement('div');
  301. entry.textContent = text;
  302. resultsContainer.appendChild(entry); // Add each result to the results container
  303. });
  304. }
  305. });
  306.  
  307. document.addEventListener('keydown', function(event) {
  308. if (event.ctrlKey && event.altKey && event.key === 'c') {
  309. try {
  310. const nestedIframeDocument = window.frames[0].frames[0].document;
  311. const contentElements = nestedIframeDocument.getElementsByClassName("content");
  312. const altElements = nestedIframeDocument.querySelectorAll('[alt]'); // Select all elements with an "alt" attribute
  313. let contentText = '';
  314.  
  315. // Process content elements
  316. if (contentElements.length > 0) {
  317. contentText = Array.from(contentElements)
  318. .map(element => element.innerText)
  319. .join('\n');
  320. } else {
  321. console.error('No elements with class="content" found.');
  322. }
  323.  
  324. // Process alt elements
  325. const altValues = Array.from(altElements)
  326. .map(element => element.getAttribute('alt')) // Get the alt attribute values
  327. .join('\n'); // Join them into a single string
  328.  
  329. // Combine content text and alt values
  330. const combinedText = contentText + (contentText && altValues ? '\n' : '') + altValues;
  331.  
  332. // Check if we have content to copy
  333. if (combinedText) {
  334. navigator.clipboard.writeText(combinedText)
  335. .then(() => {
  336. console.log('Content copied to clipboard!');
  337. })
  338. .catch(err => {
  339. console.error('Failed to copy content to clipboard:', err);
  340. });
  341. } else {
  342. console.error('No content to copy.');
  343. }
  344. } catch (TypeError) {
  345. console.error("Error accessing nested iframe or elements. Check the frame structure.");
  346. }
  347. }
  348. });
  349.  
  350. // Check for Ctrl + Alt + V
  351. document.addEventListener('keydown', function(event) {
  352. if ((event.ctrlKey || event.metaKey) && event.altKey && event.key === 'v') {
  353. event.preventDefault();
  354. const buttons = Array.from(document.querySelectorAll('button'));
  355. const buttonToClick = buttons.find(button => button.innerText === 'Search Clipboard');
  356. if (buttonToClick) {
  357. buttonToClick.click();
  358. } else {
  359. console.log('Button with the inner text "Search Clipboard" not found.');
  360. }
  361. }
  362. });
  363.  
  364. let buttonsClicked = false;
  365.  
  366. function updateTextareaAndClickButtonsOnce() {
  367. try {
  368. const iframeDoc = window.frames[0].frames[0].document;
  369.  
  370. if (iframeDoc.readyState === 'complete') {
  371. const textarea = iframeDoc.querySelector('.QuestionTextArea');
  372.  
  373. if (textarea && textarea.value.trim() === '') {
  374. const answerChoices = iframeDoc.querySelectorAll('.answer-choice-label');
  375.  
  376. let allText = '';
  377.  
  378. answerChoices.forEach(choice => {
  379. allText += choice.textContent.trim() + '\n';
  380. });
  381.  
  382. textarea.value = allText.trim();
  383.  
  384. const buttons = iframeDoc.querySelectorAll('.answer-choice-button');
  385.  
  386. buttons.forEach(button => {
  387. if (button) {
  388. button.click();
  389. } else {
  390. console.warn("Button with class 'answer-choice-button' not found.");
  391. }
  392. });
  393.  
  394. const doneButtons = iframeDoc.querySelectorAll('.done-start');
  395. setTimeout(() => {
  396. doneButtons.forEach(doneButton => {
  397. if (doneButton) {
  398. doneButton.click();
  399. } else {
  400. console.warn("Button with class 'done-start' not found.");
  401. }
  402. });
  403.  
  404. const retryButtons = iframeDoc.querySelectorAll('.done-retry');
  405. setTimeout(() => {
  406. retryButtons.forEach(retryButton => {
  407. if (retryButton) {
  408. retryButton.click();
  409. } else {
  410. console.warn("Button with class 'done-retry' not found.");
  411. }
  412. });
  413. },400);
  414. }, 200);
  415. }
  416. }
  417. } catch (error) {
  418. console.error("An error occurred:", error);
  419. }
  420. }
  421. function checkUpdateTextareaAndClickButtonsOnce() {
  422. const isAutoWritingChecked = document.getElementById('autoWritingCheckbox').checked;
  423. const element = document.getElementById('activity-title');
  424.  
  425. // Check if the element exists and contains the text "Assignment"
  426. const isAssignmentTitle = element && element.textContent.includes("Assignment");
  427.  
  428. // If it's an assignment, check the assignment specific checkbox
  429. const isAutoWritingOnAssignmentChecked = isAssignmentTitle
  430. ? document.getElementById('autoWritingOnAssignmentCheckbox').checked
  431. : true; // Default to true if not an assignment
  432.  
  433. // Call updateTextareaAndClickButtonsOnce only if the correct checkboxes are checked
  434. if (isAutoWritingChecked && (isAssignmentTitle ? isAutoWritingOnAssignmentChecked : true)) {
  435. updateTextareaAndClickButtonsOnce();
  436. }
  437. }
  438.  
  439. // Run the check every second
  440. setInterval(checkUpdateTextareaAndClickButtonsOnce, 1000);
  441.  
  442.  
  443. function checkOpacity() {
  444. if (frames[0] && frames[0].document) {
  445. var homeVideoContainer = frames[0].document.getElementById("home_video_container");
  446. if (homeVideoContainer && homeVideoContainer.parentNode.style.opacity == 1) {
  447. } else {
  448. try {
  449. if (document.getElementById("activity-title").innerText == "Assignment") {}
  450. if (["Instruction", "Summary", "Warm-Up"].includes(document.getElementById("activity-title").innerText)) {
  451. try {
  452. clickFootnavAndNextFrame();
  453. window.options = window.frames[0].frames[0].document.getElementsByClassName("answer-choice-button");
  454. window.options[Math.floor(Math.random() * window.options.length)].click();
  455. } catch (TypeError) {}
  456. try {
  457. window.frames[0].API.Frame.check();
  458. } catch (TypeError) {}
  459. }
  460. } catch (TypeError) {}
  461. }
  462. }
  463. }
  464.  
  465. function checkcheckOpacity() {
  466. const isGuessingChecked = document.getElementById('guessingCheckbox').checked;
  467. if (isGuessingChecked) {
  468. checkOpacity();
  469. }
  470. }
  471.  
  472. setInterval(checkcheckOpacity, 1000);
  473.  
  474.  
  475. setInterval(function() {
  476.  
  477. document.getElementById("invis-o-div").remove();
  478. }, 1000);
  479.  
  480.  
  481. function clickFootnavAndNextFrame() {
  482. try {
  483. document.getElementsByClassName("footnav goRight")[0].click();
  484. } catch (TypeError) {}
  485.  
  486. try {
  487. window.frames[0].API.FrameChain.nextFrame();
  488. } catch (TypeError) {}
  489. }
  490.  
  491. setInterval(function() {
  492. try {
  493. window.frames[0].document.getElementById("invis-o-div").remove();
  494. } catch (TypeError) {}
  495. }, 1000);
  496.  
  497.  
  498.  
  499. var clipboardButton;
  500.  
  501. function createClipboardSearchButton() {
  502. try {
  503. const iframe = document.querySelector("iframe");
  504. if (iframe) {
  505. const rect = iframe.getBoundingClientRect();
  506. const iframeTop = rect.top + window.scrollY;
  507. const iframeRight = rect.right + window.scrollX;
  508.  
  509. const buttonContainer = document.createElement('div');
  510. buttonContainer.style.position = 'fixed';
  511. buttonContainer.style.top = (iframeTop + 10) + 'px';
  512. buttonContainer.style.left = (iframeRight - 150) + 'px';
  513. buttonContainer.style.zIndex = '9999';
  514. document.body.appendChild(buttonContainer);
  515.  
  516. clipboardButton = document.createElement('button');
  517. clipboardButton.innerText = 'Search Clipboard';
  518. buttonContainer.appendChild(clipboardButton);
  519.  
  520. // Update URL when the clipboard changes
  521. setInterval(updateClipboardUrl, 100);
  522.  
  523. clipboardButton.onclick = function(event) {
  524. event.stopPropagation();
  525. const searchUrl = clipboardButton.getAttribute('data-url');
  526. if (searchUrl) {
  527. const isBrainlyChecked = document.getElementById('searchInBrainlyCheckbox').checked;
  528.  
  529. if (isBrainlyChecked) {
  530. const brainlyIframe = document.getElementById('brainly-chat-iframe');
  531. if (brainlyIframe) {
  532. brainlyIframe.src = searchUrl;
  533. } else {
  534. console.error('Brainly iframe not found.');
  535. }
  536. } else {
  537. window.open(searchUrl, '_blank');
  538. }
  539. }
  540. };
  541. }
  542. } catch (error) {
  543. console.error('Error accessing the first iframe:', error);
  544. }
  545. }
  546.  
  547. function updateClipboardUrl() {
  548. navigator.clipboard.readText().then(function(clipboardText) {
  549. if (clipboardText) {
  550. const searchUrl = 'https://brainly.com/app/ask?entry=top&q=' + encodeURIComponent(clipboardText);
  551. clipboardButton.setAttribute('data-url', searchUrl);
  552. }
  553. }).catch(function(err) {
  554. console.error('Could not read clipboard text: ', err);
  555. });
  556. }
  557.  
  558. function checkClipboardSearchButton() {
  559. const isClipboardChecked = document.getElementById('searchClipboardCheckbox').checked;
  560.  
  561. if (isClipboardChecked) {
  562. if (!clipboardButton) {
  563. createClipboardSearchButton();
  564. }
  565. } else {
  566. if (clipboardButton) {
  567. clipboardButton.parentElement.removeChild(clipboardButton);
  568. clipboardButton = null;
  569. }
  570. }
  571. }
  572.  
  573. setInterval(checkClipboardSearchButton, 1000);
  574. function addDeepaiIframes() {
  575. const wrapElement = document.getElementById('wrap');
  576.  
  577. if (!document.getElementById('deepai-chat-iframe')) {
  578. const deepaiIframe = document.createElement('iframe');
  579. deepaiIframe.id = 'deepai-chat-iframe';
  580. deepaiIframe.src = 'https://deepai.org/chat';
  581.  
  582. deepaiIframe.style.width = '25%';
  583. deepaiIframe.style.height = '100vh';
  584. deepaiIframe.style.border = 'none';
  585. deepaiIframe.style.position = 'absolute';
  586. deepaiIframe.style.top = '0';
  587. deepaiIframe.style.right = '0';
  588. deepaiIframe.style.zIndex = '20000';
  589. wrapElement.style.position = 'relative';
  590. deepaiIframe.style.opacity = '0';
  591. deepaiIframe.style.transition = 'opacity 0.5s';
  592. deepaiIframe.sandbox = 'allow-same-origin allow-scripts';
  593.  
  594. document.body.appendChild(deepaiIframe);
  595. }
  596. }
  597.  
  598. function addBrainlyIframes() {
  599. const wrapElement = document.getElementById('wrap');
  600.  
  601. if (!document.getElementById('brainly-chat-iframe')) {
  602. const brainlyIframe = document.createElement('iframe');
  603. brainlyIframe.id = 'brainly-chat-iframe';
  604. brainlyIframe.src = 'https://brainly.com/search';
  605.  
  606. brainlyIframe.style.width = '25%';
  607. brainlyIframe.style.height = '100vh';
  608. brainlyIframe.style.border = 'none';
  609. brainlyIframe.style.position = 'absolute';
  610. brainlyIframe.style.top = '0';
  611. brainlyIframe.style.left = '0';
  612. brainlyIframe.style.zIndex = '20000';
  613. wrapElement.style.position = 'relative';
  614. brainlyIframe.style.opacity = '0';
  615. brainlyIframe.style.transition = 'opacity 0.5s';
  616. brainlyIframe.sandbox = 'allow-same-origin allow-scripts';
  617.  
  618. document.body.appendChild(brainlyIframe);
  619. }
  620. }
  621.  
  622. addDeepaiIframes();
  623. addBrainlyIframes();
  624.  
  625. function updateDeepaiIframeVisibility() {
  626. const deepaiIframe = document.getElementById('deepai-chat-iframe');
  627. const isAiChatChecked = document.getElementById('aiChatCheckbox').checked;
  628.  
  629. if (deepaiIframe) {
  630. if (isAiChatChecked) {
  631. deepaiIframe.style.opacity = '1';
  632. deepaiIframe.style.display = 'block';
  633. } else {
  634. deepaiIframe.style.opacity = '0';
  635. setTimeout(() => deepaiIframe.style.display = 'none', 500);
  636. }
  637. }
  638. }
  639.  
  640. function updateBrainlyIframeVisibility() {
  641. const brainlyIframe = document.getElementById('brainly-chat-iframe');
  642. const isBrainlyChecked = document.getElementById('searchInBrainlyCheckbox').checked;
  643.  
  644. if (brainlyIframe) {
  645. if (isBrainlyChecked) {
  646. brainlyIframe.style.opacity = '1';
  647. brainlyIframe.style.display = 'block';
  648. } else {
  649. brainlyIframe.style.opacity = '0';
  650. setTimeout(() => brainlyIframe.style.display = 'none', 500);
  651. }
  652. }
  653. }
  654.  
  655. setInterval(() => {
  656. updateDeepaiIframeVisibility();
  657. updateBrainlyIframeVisibility();
  658. }, 1000);
  659. function createButtonAndPane() {
  660. if (document.querySelector('#tweaksButton')) return;
  661.  
  662. const mainFootDiv = document.querySelector('.mainfoot');
  663.  
  664. const toggleButton = document.createElement('button');
  665. toggleButton.id = 'tweaksButton';
  666. toggleButton.textContent = 'Toggle Options';
  667.  
  668. // Apply styles to the button
  669. toggleButton.style.border = "1px solid #5f5f5f";
  670. toggleButton.style.boxShadow = "inset 0 0 5px rgba(0, 0, 0, 0.6)";
  671. toggleButton.style.backgroundColor = "rgb(39, 39, 39)";
  672. toggleButton.style.color = "#f9a619";
  673. toggleButton.style.borderRadius = "3px";
  674. toggleButton.style.marginLeft = "40%";
  675. toggleButton.style.zIndex = "2";
  676. toggleButton.style.padding = '5px 10px';
  677.  
  678. mainFootDiv.appendChild(toggleButton);
  679.  
  680. if (!window.pane) {
  681. window.pane = document.createElement('div');
  682. window.pane.style.display = 'none';
  683. document.body.appendChild(window.pane);
  684.  
  685. const popupMenu = document.createElement('div');
  686. popupMenu.className = 'popup-menu';
  687.  
  688. const aiChatItem = createMenuItem('AI Chat', 'aiChatCheckbox');
  689. popupMenu.appendChild(aiChatItem);
  690.  
  691. const searchInBrainlyItem = createMenuItem('Search in Brainly frame', 'searchInBrainlyCheckbox');
  692. popupMenu.appendChild(searchInBrainlyItem);
  693.  
  694. const autoVocabItem = createMenuItem('Auto Vocab', 'autoVocabCheckbox');
  695. popupMenu.appendChild(autoVocabItem);
  696.  
  697. const autoWritingItem = createMenuItem('Auto Writing', 'autoWritingCheckbox');
  698. popupMenu.appendChild(autoWritingItem);
  699.  
  700. const autoplayItem = createMenuItem('Autoplay', 'autoplayCheckbox');
  701. popupMenu.appendChild(autoplayItem);
  702.  
  703. const searchClipboardItem = createMenuItem('Search Clipboard Button', 'searchClipboardCheckbox');
  704. popupMenu.appendChild(searchClipboardItem);
  705.  
  706. const guessingItem = createMenuItem('Guessing', 'guessingCheckbox');
  707. popupMenu.appendChild(guessingItem);
  708.  
  709. const autoWritingOnAssignmentItem = createMenuItem('AutoWriting On Assignment', 'autoWritingOnAssignmentCheckbox');
  710. popupMenu.appendChild(autoWritingOnAssignmentItem);
  711.  
  712. window.pane.appendChild(popupMenu);
  713.  
  714. const footerText = document.createElement('div');
  715. footerText.style.marginTop = '20px';
  716. footerText.style.color = 'rgb(249, 166, 25)';
  717. footerText.style.textAlign = "center";
  718. footerText.textContent = "This was made by me, TallTacoTristan, as a way to make edge-nuity " +
  719. "classes MUCH easier and skip by the tedious bits but it took a long time, probably over " +
  720. "24 hours of just coding, to write over half a thousand lines, it has many features, " +
  721. "the ones above are less than half, just the ones that need a toggle. " +
  722. "So please leave a good review on my page for all the time I spent to save yours, Thank you.";
  723. window.pane.appendChild(footerText);
  724.  
  725. loadCheckboxState('aiChat', 'aiChatCheckbox');
  726. loadCheckboxState('searchInBrainly', 'searchInBrainlyCheckbox');
  727. loadCheckboxState('autoVocab', 'autoVocabCheckbox');
  728. loadCheckboxState('autoWriting', 'autoWritingCheckbox');
  729. loadCheckboxState('autoplay', 'autoplayCheckbox');
  730. loadCheckboxState('searchClipboard', 'searchClipboardCheckbox');
  731. loadCheckboxState('guessing', 'guessingCheckbox');
  732. loadCheckboxState('autoWritingOnAssignment', 'autoWritingOnAssignmentCheckbox');
  733.  
  734. // Make the pane draggable
  735. makeDraggable(window.pane);
  736. }
  737.  
  738. toggleButton.addEventListener('click', function() {
  739. console.log('Button clicked! Toggling pane visibility.');
  740.  
  741. if (window.pane.style.display === 'none' || window.pane.style.display === '') {
  742. window.pane.style.width = "50%";
  743. window.pane.style.height = "auto";
  744. window.pane.style.position = "absolute";
  745. window.pane.style.marginTop = "20vh";
  746. window.pane.style.marginLeft = "25%";
  747. window.pane.style.border = "1px solid rgb(95, 95, 95)";
  748. window.pane.style.borderRadius = "3px";
  749. window.pane.style.backgroundColor = "rgb(39, 39, 39)";
  750. window.pane.style.overflow = "hidden";
  751. window.pane.style.color = "rgb(249, 166, 25)";
  752. window.pane.style.textAlign = "center";
  753. window.pane.style.overflowY = "scroll";
  754. window.pane.style.display = 'block';
  755.  
  756. checkCheckboxState('aiChatCheckbox');
  757. checkCheckboxState('searchInBrainlyCheckbox');
  758. checkCheckboxState('autoVocabCheckbox');
  759. checkCheckboxState('autoWritingCheckbox');
  760. checkCheckboxState('autoplayCheckbox');
  761. checkCheckboxState('searchClipboardCheckbox');
  762. checkCheckboxState('guessingCheckbox');
  763. checkCheckboxState('autoWritingOnAssignmentCheckbox');
  764. } else {
  765. window.pane.style.display = 'none';
  766. }
  767. });
  768. }
  769.  
  770. function makeDraggable(element) {
  771. let offsetX, offsetY;
  772.  
  773. element.addEventListener('mousedown', function(e) {
  774. e.preventDefault();
  775. offsetX = e.clientX - element.getBoundingClientRect().left;
  776. offsetY = e.clientY - element.getBoundingClientRect().top;
  777. element.classList.add('dragging');
  778.  
  779. document.addEventListener('mousemove', dragElement);
  780. document.addEventListener('mouseup', stopDragging);
  781. });
  782.  
  783. function dragElement(e) {
  784. e.preventDefault();
  785. // Adjust x and y position based on offset with an additional offset for the Northwest position
  786. let x = e.clientX - offsetX - (element.offsetWidth * 0.2); // 20% to the left
  787. let y = e.clientY - offsetY - (element.offsetHeight * 0.9); // 20% up
  788.  
  789. // Set the new position of the element
  790. element.style.left = x + 'px';
  791. element.style.top = y + 'px';
  792. }
  793.  
  794. function stopDragging() {
  795. element.classList.remove('dragging');
  796. document.removeEventListener('mousemove', dragElement);
  797. document.removeEventListener('mouseup', stopDragging);
  798. }
  799. }
  800. function createMenuItem(text, checkboxId) {
  801. const itemDiv = document.createElement('div');
  802. itemDiv.className = 'menu-item';
  803.  
  804. const checkbox = document.createElement('input');
  805. checkbox.type = 'checkbox';
  806. checkbox.id = checkboxId;
  807.  
  808. const storedValue = localStorage.getItem(checkboxId);
  809. if (storedValue !== null) {
  810. checkbox.checked = (storedValue === 'true');
  811. }
  812.  
  813. const label = document.createElement('label');
  814. label.innerText = text;
  815. label.setAttribute('for', checkboxId);
  816.  
  817. itemDiv.appendChild(checkbox);
  818. itemDiv.appendChild(label);
  819.  
  820. checkbox.addEventListener('change', () => {
  821. console.log(`${text} checkbox is now ${checkbox.checked ? 'checked' : 'unchecked'}`);
  822. localStorage.setItem(checkboxId, checkbox.checked);
  823. });
  824.  
  825. return itemDiv;
  826. }
  827.  
  828. function loadCheckboxState(checkboxId) {
  829. const storedValue = localStorage.getItem(checkboxId);
  830. if (storedValue !== null) {
  831. const checkbox = document.getElementById(checkboxId);
  832. if (checkbox) {
  833. checkbox.checked = (storedValue === 'true');
  834. }
  835. }
  836. }
  837.  
  838. function checkCheckboxState(checkboxId) {
  839. const checkbox = document.getElementById(checkboxId);
  840. const storedValue = localStorage.getItem(checkboxId);
  841.  
  842. if (storedValue !== null && checkbox) {
  843. if (checkbox.checked !== (storedValue === 'true')) {
  844. checkbox.checked = (storedValue === 'true');
  845. }
  846. }
  847. }
  848.  
  849. setInterval(createButtonAndPane, 1000);
  850. var checkbox = document.getElementById('searchInBrainlyCheckbox');
  851.  
  852.  
  853.  
  854.  
  855.  
  856. let lastTitle = '';
  857.  
  858. function checkForAssignment() {
  859. const element = document.getElementById('activity-title');
  860. if (element) {
  861. const currentTitle = element.textContent || element.innerText;
  862.  
  863. const excludedKeywords = [
  864. "Summary", "Warm-Up", "Instruction", "Quiz",
  865. "Assignment", "Unit Test",
  866. "Unit Review", "Cumulative Exam Review",
  867. "Vocab","Cumulative Exam"
  868. ];
  869.  
  870. const containsExcludedKeyword = excludedKeywords.some(keyword => currentTitle.includes(keyword));
  871. const currentContainsAssignment = currentTitle.includes("Assignment");
  872.  
  873. if (currentTitle !== lastTitle) {
  874. if (currentContainsAssignment || !containsExcludedKeyword) {
  875. new Notification("Done!");
  876. }
  877. lastTitle = currentTitle;
  878. }
  879. }
  880. }
  881. setInterval(checkForAssignment, 1000);
  882. const isAutoVocabChecked = document.getElementById('autoVocabCheckbox').checked;
  883.  
  884. function vocabCompleter() {
  885. if (isAutoVocabChecked) {
  886. if (document.getElementById("activity-title").innerText == "Vocabulary") {
  887. try {
  888. window.frames[0].document.getElementsByClassName("word-textbox")[0].value =
  889. window.frames[0].document.getElementsByClassName("word-background")[0].value;
  890. } catch (TypeError) {}
  891. try {
  892. for (var x of window.frames[0].document.getElementsByClassName("playbutton vocab-play")) {
  893. x.click();
  894. }
  895. } catch (TypeError) {}
  896. try {
  897. window.frames[0].document.getElementsByClassName("uibtn uibtn-blue uibtn-arrow-next")[0].click();
  898. } catch (TypeError) {}
  899.  
  900. clickFootnavAndNextFrame();
  901. }
  902. }
  903. }
  904. setInterval(vocabCompleter, 1000);
  905. setInterval(() => {
  906. const activityTitle = document.getElementById("activity-title").innerText;
  907. const homeVideoContainer = document.querySelector('.home-video-container');
  908. const shouldClick = !(
  909. homeVideoContainer &&
  910. homeVideoContainer.parentNode.style.opacity == "1"
  911. );
  912.  
  913. if (shouldClick && !["Assignment", "Quiz"].includes(activityTitle)) {
  914. const goRightButton = document.querySelector(".FrameRight");
  915. if (goRightButton) {
  916. goRightButton.onclick();
  917. }
  918. const iconButton = document.querySelector(".nav-icon[data-bind='realEnable: $root.stageView().nextEnabled']");
  919. if (iconButton) {
  920. iconButton.click();
  921. }
  922. }
  923. }, 1000);
  924.  
  925.  
  926. let successCount = 0;
  927. const requiredSuccesses = 600;
  928. const checkInterval = 1000;
  929.  
  930. const checkCondition = () => {
  931. if (frames[0] && frames[0].document) {
  932. const homeVideoContainer = frames[0].document.getElementById("home_video_container");
  933. if (homeVideoContainer && homeVideoContainer.parentNode.style.opacity == 1) {
  934. successCount++;
  935. if (successCount >= requiredSuccesses) {
  936. new Notification("Reload Page!");
  937. successCount = 0;
  938. }
  939. } else {
  940. successCount = 0;
  941. }
  942. } else {
  943. successCount = 0;
  944. }
  945. };
  946.  
  947. const intervalId = setInterval(checkCondition, checkInterval);
  948.  
  949.  
  950. (function() {
  951. 'use strict';
  952.  
  953. // Get the current URL and previous URL from GM_value
  954. const currentUrl = window.location.href;
  955. const previousUrl = GM_getValue("previousHref");
  956.  
  957. // If the current URL is Brainly
  958. if (currentUrl.includes("brainly")) {
  959. // Check if the previous URL does not match the current URL
  960. if (previousUrl !== currentUrl) {
  961. // Prompt the user for a number
  962. const userInput = prompt("Please enter a number:");
  963.  
  964. // Check if the input is a valid number
  965. if (!isNaN(userInput) && userInput !== null) {
  966. // Store the input value
  967. GM_setValue("numberFromBrainly", userInput);
  968. }
  969. }
  970. }
  971.  
  972. // Function to check for changes and alert the number if it exists
  973. function checkForNumber() {
  974. // Retrieve the stored number value
  975. const storedNumber = GM_getValue("numberFromBrainly");
  976.  
  977. // Alert the number if it exists
  978. if (storedNumber) {
  979. alert("The number you entered on Brainly is: " + storedNumber);
  980. // Clear the stored value after alerting
  981. GM_setValue("numberFromBrainly", null);
  982. }
  983. }
  984.  
  985. // If the current URL is Google, set an interval to check for the number
  986. if (currentUrl.includes("google")) {
  987. setInterval(checkForNumber, 1000); // Check every second (1000 milliseconds)
  988. }
  989.  
  990. // Store the current URL as the previous URL for future comparisons
  991. GM_setValue("previousHref", currentUrl);
  992. })();
  993.  
  994. click ctrl+s to make sure the change is saved then you can close the tab
  995.  
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011. 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
  1012. click ctrl+a then ctrl+v to make this the new script:
  1013. // ==UserScript==
  1014. // @name Open the show clipboard button in background tab
  1015. // @author TTT
  1016. // @description Open the show clipboard button in background tab
  1017. // @grant GM_openInTab
  1018. // @include *://*core.learn*/*
  1019. // @run-at document-start
  1020. // @version 1.0
  1021. // @require https://greasyfork.org/scripts/12228/code/setMutationHandler.js
  1022. // ==/UserScript==
  1023.  
  1024. attachHandler([].slice.call(document.getElementsByTagName('a')));
  1025.  
  1026. attachButtonHandler([].slice.call(document.getElementsByTagName('button')));
  1027.  
  1028. setMutationHandler(document, 'button', function(nodes) {
  1029. attachButtonHandler(nodes);
  1030. return true;
  1031. });
  1032.  
  1033. function attachHandler(nodes) {
  1034. nodes.forEach(function(node) {
  1035. if (node.target !== '_blank') {
  1036. node.onclick = clickHandler;
  1037. node.addEventListener('click', clickHandler);
  1038. }
  1039. });
  1040. }
  1041.  
  1042. function attachButtonHandler(buttons) {
  1043. buttons.forEach(function(button) {
  1044. button.onclick = buttonClickHandler;
  1045. button.addEventListener('click', buttonClickHandler);
  1046. });
  1047. }
  1048.  
  1049. function clickHandler(e) {
  1050. const href = this.href;
  1051. if (href.includes('brainly.com')) {
  1052. if (e.button > 1) return;
  1053. e.preventDefault();
  1054. e.stopPropagation();
  1055. e.stopImmediatePropagation();
  1056. GM_openInTab(href, true);
  1057. }
  1058. }
  1059.  
  1060. function buttonClickHandler(e) {
  1061. const url = this.getAttribute('data-url');
  1062. if (url && url.includes('brainly.com')) {
  1063. if (e.button > 1) return;
  1064. e.preventDefault();
  1065. e.stopPropagation();
  1066. e.stopImmediatePropagation();
  1067.  
  1068. GM_openInTab(url, true);
  1069. }
  1070. }
  1071.  
  1072.  
  1073. make sure to also save this by ctrl+s
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085. Then lastly, make this a new script as well by doing the same things
  1086. // ==UserScript==
  1087. // @name Match options to brainly
  1088. // @namespace http://tampermonkey.net/
  1089. // @version 2024-11-24
  1090. // @description try to take over the world!
  1091. // @author You
  1092. // @match https://brainly.com/*
  1093. // @include *://*core.learn*/*
  1094. // @icon https://www.google.com/s2/favicons?sz=64&domain=brainly.com
  1095. // @grant GM_setValue
  1096. // @grant GM_getValue
  1097. // ==/UserScript==
  1098. (function() {
  1099. 'use strict';
  1100.  
  1101. let lastUrl = ""; // Store the last known URL
  1102. let lastStoredValue = null;
  1103.  
  1104. // Function to get the text from the results container
  1105. function getResultsContainerTexts() {
  1106. const resultsContainer = document.getElementById('results-container');
  1107. const childrenTexts = Array.from(resultsContainer.children).map(child => child.innerText.trim());
  1108. return childrenTexts;
  1109. }
  1110.  
  1111. // Function to continuously check and update GM values
  1112. function updateGMValues() {
  1113. const texts = getResultsContainerTexts();
  1114.  
  1115. // Update GM values for each child
  1116. texts.forEach((text, index) => {
  1117. GM_setValue(`childText${index + 1}`, text); // Store text for child 1, 2, 3, 4
  1118. });
  1119. }
  1120.  
  1121. // Function to check for direct matches with GM values (returns last match)
  1122. function checkDirectMatches(textContents) {
  1123. let lastMatch = null; // Variable to keep track of the last match
  1124.  
  1125. for (let i = 1; i <= 4; i++) {
  1126. const childValue = GM_getValue(`childText${i}`);
  1127. for (const line of textContents) {
  1128. if (line.includes(childValue)) {
  1129. lastMatch = { match: childValue, childIndex: i }; // Update last match found
  1130. }
  1131. }
  1132. }
  1133.  
  1134. // If a last match was found, update the GM value
  1135. if (lastMatch) {
  1136. const sanitizedValue = String.fromCharCode(64 + lastMatch.childIndex); // Convert index to letter A-D
  1137. GM_setValue("numberFromBrainly", sanitizedValue);
  1138. console.log("Last direct match found, value set for numberFromBrainly:", sanitizedValue);
  1139. return true; // Indicate a match was found
  1140. }
  1141. return false; // Indicate no matches found
  1142. }
  1143.  
  1144. // Function to check regex matches if no direct matches are found
  1145. function checkRegexMatches(textContents) {
  1146. const digitToLetterMap = {
  1147. '1': 'A',
  1148. '2': 'B',
  1149. '3': 'C',
  1150. '4': 'D'
  1151. };
  1152.  
  1153. const keywordToLetterMap = {
  1154. 'first': 'A',
  1155. 'second': 'B',
  1156. 'third': 'C',
  1157. 'fourth': 'D',
  1158. 'option one': 'A',
  1159. 'option two': 'B',
  1160. 'option three': 'C',
  1161. 'option four': 'D'
  1162. };
  1163.  
  1164. // Updated regex patterns
  1165. const patterns = [
  1166. /(?<!\w)([Aa][.)])/i,
  1167. /(?<!\w)([Bb][.)])/i,
  1168. /(?<!\w)([Cc][.)])/i,
  1169. /(?<!\w)([Dd][.)])/i,
  1170. /\boption\s*\(\s*([a-dA-D1-4])\s*\)/i,
  1171. /\boption\s*([a-dA-D1-4])\b/i,
  1172. /\(\s*([a-dA-D1-4])\s*\)/,
  1173. /(?:^|\s)([1-4])(?:\s|$)/,
  1174. /\b(first|second|third|fourth)\b/i,
  1175. /\b(option one|option two|option three|option four)\b/i
  1176. ];
  1177.  
  1178. let validOption = null;
  1179.  
  1180. // Check each text content for regex matches
  1181. for (const line of textContents) {
  1182. for (const pattern of patterns) {
  1183. const match = line.match(pattern);
  1184. if (match) {
  1185. if (digitToLetterMap[match[1]]) {
  1186. validOption = digitToLetterMap[match[1]];
  1187. } else if (keywordToLetterMap[match[1].toLowerCase()]) {
  1188. validOption = keywordToLetterMap[match[1].toLowerCase()];
  1189. } else {
  1190. validOption = match[1].toUpperCase();
  1191. }
  1192.  
  1193. break; // Break after first valid match
  1194. }
  1195. }
  1196. if (validOption) break; // Exit if a valid option is found
  1197. }
  1198.  
  1199. // If a valid option is found, set it as numberFromBrainly
  1200. if (validOption) {
  1201. GM_setValue("numberFromBrainly", validOption);
  1202. console.log("Regex match found, value set for numberFromBrainly:", validOption);
  1203. }
  1204. return validOption; // Return the matched option for further processing
  1205. }
  1206.  
  1207. // Function to execute when the href changes
  1208. function checkAnswerBoxes() {
  1209. const answerBoxes = document.querySelectorAll('[data-testid="answer_box_content"]');
  1210. const textContents = Array.from(answerBoxes).map(box => box.innerText.trim());
  1211.  
  1212. const foundDirectMatch = checkDirectMatches(textContents); // Check for direct matches
  1213. let matchedOption = null;
  1214.  
  1215. // Only check regex matches if no direct matches found
  1216. if (!foundDirectMatch) {
  1217. matchedOption = checkRegexMatches(textContents); // Check regex matches and store matched option
  1218. }
  1219.  
  1220. replaceStoredValueAndClick(matchedOption || GM_getValue("numberFromBrainly"));
  1221. }
  1222.  
  1223. // Function to handle clicking the appropriate answer button
  1224. function replaceStoredValueAndClick(storedNumber) {
  1225. const activityTitleElement = document.getElementById("activity-title");
  1226. if (activityTitleElement) {
  1227. const activityTitleText = activityTitleElement.textContent || activityTitleElement.innerText;
  1228.  
  1229. // Only proceed if in the context of "Test", "Exam", or "Quiz"
  1230. if (activityTitleText.includes("Test") || activityTitleText.includes("Exam") || activityTitleText.includes("Quiz")) {
  1231. const iframeDocument = window.frames[0].document;
  1232.  
  1233. // Get the target elements containing the question
  1234. const targetElements = iframeDocument.getElementsByClassName("Assessment_Main_Body_Content_Question");
  1235.  
  1236. // Filter elements that are visible and have 'q_' in their id
  1237. const visibleElements = Array.from(targetElements).filter(function(element) {
  1238. return element.style.display !== "none" && element.id.includes("q_");
  1239. });
  1240.  
  1241. // Find visible answer buttons within these visible question elements
  1242. const answerButtons = [];
  1243. visibleElements.forEach(function(questionElement) {
  1244. const buttons = questionElement.getElementsByClassName("answer-choice-button");
  1245. answerButtons.push(...Array.from(buttons).filter(button => button.style.display !== "none"));
  1246. });
  1247.  
  1248. // Determine which button to click based on the stored number
  1249. if (storedNumber) {
  1250. const index = { "A": 0, "B": 1, "C": 2, "D": 3 }[storedNumber];
  1251. if (index !== undefined && answerButtons.length > index) {
  1252. answerButtons[index].click(); // Click the corresponding button
  1253. } else {
  1254. console.log("Stored number does not correspond to a valid answer button index.");
  1255. }
  1256. }
  1257. }
  1258. }
  1259. }
  1260. // Function to handle the URL changes
  1261. function handleNewUrl() {
  1262. const currentUrl = window.location.href;
  1263.  
  1264. if (currentUrl.includes("brainly.com/question") && lastUrl !== currentUrl) {
  1265. GM_setValue("numberFromBrainly", null);
  1266. console.log("Value for numberFromBrainly set to null due to URL change:", currentUrl);
  1267. lastUrl = currentUrl; // Update last known URL
  1268. checkAnswerBoxes(); // There is a URL change; check the answer boxes
  1269. }
  1270.  
  1271. if (currentUrl.includes("core.learn")) {
  1272. const storedNumber = GM_getValue("numberFromBrainly");
  1273. if (storedNumber !== lastStoredValue) {
  1274. lastStoredValue = storedNumber; // Update last stored value
  1275. replaceStoredValueAndClick(storedNumber); // Attempt to click based on updated stored number
  1276. }
  1277. }
  1278. }
  1279.  
  1280. // Observe changes to the document's URL and changes in GM value
  1281. const observer = new MutationObserver((mutations) => {
  1282. if (mutations.some(mutation => mutation.type === 'childList' || mutation.type === 'attributes')) {
  1283. handleNewUrl();
  1284. }
  1285. });
  1286.  
  1287. // Start observing for changes in the document
  1288. observer.observe(document.body, {
  1289. childList: true,
  1290. subtree: true,
  1291. attributes: true
  1292. });
  1293.  
  1294. // Initial check when the script runs
  1295. setInterval(updateGMValues, 100); // Update every 0.1 seconds
  1296. checkAnswerBoxes();
  1297.  
  1298. })();
  1299. let lastValue = GM_getValue("numberFromBrainly");
  1300.  
  1301. function getAnswerButtonIndex(letter) {
  1302. switch (letter.toLowerCase().replace(/[^a-d]/g, '')) {
  1303. case 'a':
  1304. return 0; // First button (index 0)
  1305. case 'b':
  1306. return 1; // Second button (index 1)
  1307. case 'c':
  1308. return 2; // Third button (index 2)
  1309. case 'd':
  1310. return 3; // Fourth button (index 3)
  1311. default:
  1312. return -1; // Invalid letter
  1313. }
  1314. }
  1315.  
  1316. function checkForChanges() {
  1317. const currentValue = GM_getValue("numberFromBrainly");
  1318.  
  1319. if (currentValue !== lastValue) {
  1320. lastValue = currentValue; // Update last value
  1321.  
  1322. // Extract the letter from the current value
  1323. const letter = currentValue.match(/[a-dA-D][).]?/);
  1324. if (letter) {
  1325. const index = getAnswerButtonIndex(letter[0]);
  1326. if (index !== -1) {
  1327. const activityTitleElement = document.getElementById("activity-title");
  1328.  
  1329. if (activityTitleElement) {
  1330. const activityTitleText = activityTitleElement.textContent || activityTitleElement.innerText;
  1331.  
  1332. // Only proceed if in the context of "Test", "Exam", or "Quiz"
  1333. if (activityTitleText.includes("Test") || activityTitleText.includes("Exam") || activityTitleText.includes("Quiz")) {
  1334. const iframeDocument = window.frames[0].document;
  1335.  
  1336. // Get the target elements containing the question
  1337. const targetElements = iframeDocument.getElementsByClassName("Assessment_Main_Body_Content_Question");
  1338.  
  1339. // Filter elements that are visible and have 'q_' in their id
  1340. const visibleElements = Array.from(targetElements).filter(function(element) {
  1341. return element.style.display !== "none" && element.id.includes("q_");
  1342. });
  1343.  
  1344. // Find visible answer buttons within these visible question elements
  1345. const answerButtons = [];
  1346. visibleElements.forEach(function(questionElement) {
  1347. const buttons = questionElement.getElementsByClassName("answer-choice-button");
  1348. answerButtons.push(...Array.from(buttons).filter(button => button.style.display !== "none"));
  1349. });
  1350.  
  1351. // Click the corresponding answer button
  1352. if (answerButtons[index]) {
  1353. answerButtons[index].click();
  1354. }
  1355. }
  1356. }
  1357. }
  1358. }
  1359. }
  1360. }
  1361.  
  1362. // Start checking for changes every 100 milliseconds
  1363. setInterval(checkForChanges, 100);
  1364.  
  1365. after saving, youre done and now click "3" on your keyboard whenever you want an autoanswer search
  1366. ALSO make sure you click outside of the test frame before clicking the key
  1367. Enjoy:)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement