Edge-nuity Megascript

Completes through instructional, summary, and warm-up sections by guessing answers (they don’t impact grades). You can begin activities while the instructor is speaking, when theres an activity, a "Search clipboard" button appears for quick access to answers during quizzes (will search your copied text on brainly and auto-redirect) And much more (read desc).

目前为 2024-12-23 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Edge-nuity Megascript
  3. // @version 1.6
  4. // @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).
  5. // @author TTT
  6. // @license MIT
  7. // @include *://*core.learn*/*
  8. // @include https://brainly.com/*
  9. // @grant none
  10. // @namespace https://www.tampermonkey.net/
  11. // ==/UserScript==
  12. const checkElementVisibility = (element) => {
  13. const boundingRect = element.getBoundingClientRect();
  14. const computedStyle = window.getComputedStyle(element);
  15. return (
  16. computedStyle.opacity !== '0' &&
  17. computedStyle.visibility !== 'hidden' &&
  18. computedStyle.display !== 'none' &&
  19. boundingRect.width > 0 &&
  20. boundingRect.height > 0
  21. );
  22. };
  23.  
  24. const checkForTimerStayElement = () => {
  25. const targetElement = document.getElementById('timerStay');
  26.  
  27. if (targetElement && checkElementVisibility(targetElement)) {
  28. const simulatedClickEvent = new MouseEvent('click', {
  29. view: window,
  30. bubbles: true,
  31. cancelable: true
  32. });
  33. targetElement.dispatchEvent(simulatedClickEvent);
  34. }
  35. };
  36. if (window.top === window.self) {
  37. const intervalId = setInterval(checkForTimerStayElement, 100);
  38. }
  39.  
  40. let videoElement = null;
  41. let alertTriggered = false;
  42. let alertScheduled = false;
  43.  
  44. const callback = function(mutationsList, observer) {
  45. for (const mutation of mutationsList) {
  46. if (mutation.type === 'childList') {
  47. videoElement = document.getElementById("home_video_js");
  48. if (videoElement) {
  49. startCheckingVideo();
  50.  
  51. observer.disconnect();
  52. }
  53. }
  54. }
  55. };
  56.  
  57. const config = {
  58. attributes: false,
  59. childList: true,
  60. subtree: true
  61. };
  62.  
  63. const targetNode = document.body;
  64. const observer = new MutationObserver(callback);
  65. observer.observe(targetNode, config);
  66.  
  67. function startCheckingVideo() {
  68. setInterval(() => {
  69. if (videoElement) {
  70. const currentTime = videoElement.currentTime;
  71. const duration = videoElement.duration;
  72.  
  73. if (currentTime >= duration) {
  74. if (!alertScheduled) {
  75. alertScheduled = true;
  76. let checksCount = 0;
  77. let allChecksPassed = true;
  78.  
  79. const intervalId = setInterval(() => {
  80. const homeVideoContainer = document.getElementById("home_video_container");
  81. if (homeVideoContainer && homeVideoContainer.parentNode.style.opacity == 1) {
  82. checksCount++;
  83. } else {
  84. allChecksPassed = false;
  85. }
  86.  
  87. if (checksCount === 10) {
  88. clearInterval(intervalId);
  89. if (allChecksPassed) {
  90. new Notification("Reload!");
  91. alertTriggered = true;
  92. }
  93. alertScheduled = false;
  94. }
  95. }, 100);
  96. }
  97. } else {
  98. alertTriggered = false;
  99. }
  100. }
  101. }, 550);
  102. }
  103.  
  104.  
  105. (function() {
  106. 'use strict';
  107.  
  108. let completeCount = 0;
  109.  
  110. const originalConsoleLog = console.log;
  111. console.log = function() {
  112. const message = Array.from(arguments).join(' ');
  113. if (message.includes('complete')) {
  114. completeCount++;
  115. if (completeCount === 2) {
  116. const goRightButton = document.querySelector('li.FrameRight a');
  117. if (goRightButton) {
  118. goRightButton.click();
  119. completeCount = 0;
  120. }
  121. }
  122. }
  123. originalConsoleLog.apply(console, arguments);
  124. };
  125. })();
  126. function checkAutoplay() {
  127. const isAutoplayChecked = document.getElementById('autoplayCheckbox').checked;
  128. if (isAutoplayChecked) {
  129. playVideo();
  130. }
  131. }
  132. if (window.top === window.self) {
  133. setInterval(checkAutoplay, 1000);}
  134.  
  135. function playVideo() {
  136. var playButton = window.frames[0].document.getElementById("uid1_play");
  137. if (playButton != undefined) {
  138. setTimeout(function() {
  139. if (playButton.className == "play") {
  140. playButton.children[0].click();
  141. }
  142. }, 1000);
  143. }
  144. }
  145.  
  146. function showColumn() {
  147. try {
  148. window.frames[0].frames[0].document.getElementsByClassName("right-column")[0].children[0].style.display = "block";
  149. } catch (TypeError) {}
  150.  
  151. try {
  152. window.frames[0].frames[0].document.getElementsByClassName("left-column")[0].children[0].style.display = "block";
  153. } catch (TypeError) {}
  154. }
  155. if (window.top === window.self) {
  156. setInterval(showColumn, 1000);}
  157.  
  158.  
  159. function clearLocalStorage() {
  160. try {
  161. localStorage.clear();
  162. } catch (error) {}
  163. }
  164.  
  165. function removeElementsByClassName(className) {
  166. var elements = document.getElementsByClassName(className);
  167. Array.prototype.forEach.call(elements, function(element) {
  168. try {
  169. element.parentNode.removeChild(element);
  170. } catch (error) {}
  171. });
  172. }
  173.  
  174. function handleOnload() {
  175. var classNamesToRemove = [
  176. "brn-expanded-bottom-banner",
  177. "brn-brainly-plus-box",
  178. "brn-fullscreen-toplayer",
  179. "sg-overlay sg-overlay--dark"
  180. ];
  181. classNamesToRemove.forEach(function(className) {
  182. removeElementsByClassName(className);
  183. });
  184. }
  185.  
  186. if (window.location.href.includes("brainly.com")) {
  187. clearLocalStorage();
  188. handleOnload();
  189. }
  190.  
  191. function redirectToFirstSearchItem() {
  192. if (window.location.href.startsWith('https://brainly.com/app/ask')) {
  193. const searchItem = document.querySelector('[data-testid="search-item-facade-wrapper"]');
  194. if (searchItem) {
  195. const anchorElement = searchItem.querySelector('a');
  196. if (anchorElement) {
  197. const href = anchorElement.getAttribute('href');
  198. const fullUrl = `https://brainly.com${href}`;
  199. window.location.href = fullUrl;
  200. clearInterval(interval);
  201. }
  202. }
  203. }
  204. }
  205. const interval = setInterval(redirectToFirstSearchItem, 1000);
  206.  
  207.  
  208.  
  209. function checkElement() {
  210. const element = document.querySelector('[data-testid="answer_box"][data-test="locked_answer"]');
  211.  
  212. if (element && document.location.href.includes("brainly.com/question")) {
  213. location.reload();
  214. }
  215. }if (window.top === window.self) {
  216. setInterval(checkElement, 750);}
  217.  
  218.  
  219.  
  220. function extractTextFromIframe() {
  221. var iframeDocument = window.frames[0].document;
  222.  
  223. var targetElements = iframeDocument.getElementsByClassName("Assessment_Main_Body_Content_Question");
  224.  
  225. var visibleElements = Array.from(targetElements).filter(function(element) {
  226. return element.style.display !== "none" && element.id.includes("q_");
  227. });
  228.  
  229. if (visibleElements.length > 0) {
  230. var finalTextOutput = [];
  231.  
  232. var regex = />([^<]+)</g;
  233. var regexSpecial = /»([^«]+)«/g;
  234. var regexCleanUp = /[\n\r]+|<[^>]*>|&nbsp;| /g;
  235.  
  236. visibleElements.forEach(function(targetElement) {
  237. var elementText = "";
  238.  
  239. let matches;
  240. while ((matches = regex.exec(targetElement.innerHTML)) !== null) {
  241. var extractedText = matches[1].trim();
  242. if (extractedText && !/(class|src|align|style)=/i.test(extractedText)) {
  243. elementText += extractedText + " ";
  244. }
  245. }
  246.  
  247. while ((matches = regexSpecial.exec(targetElement.innerHTML)) !== null) {
  248. var extractedText = matches[1].trim();
  249. if (extractedText && !/(class|src|align|style)=/i.test(extractedText)) {
  250. elementText += extractedText + " ";
  251. }
  252. }
  253.  
  254. var imgElements = targetElement.getElementsByTagName("img");
  255. Array.from(imgElements).forEach(function(img) {
  256. if (img.alt) {
  257. elementText += img.alt.trim() + " ";
  258. }
  259. });
  260.  
  261. elementText = elementText.replace(regexCleanUp, ' ').trim();
  262. elementText = elementText.replace(/\u00A0/g, ' ');
  263.  
  264. if (elementText) {
  265. finalTextOutput.push(elementText);
  266. }
  267. });
  268.  
  269. var tempTextArea = document.createElement("textarea");
  270. tempTextArea.value = finalTextOutput.join("\n").replace(/\s+/g, ' ');
  271.  
  272. document.body.appendChild(tempTextArea);
  273. tempTextArea.select();
  274. document.execCommand("Copy");
  275. document.body.removeChild(tempTextArea);
  276.  
  277. setTimeout(function() {
  278. var buttons = Array.from(document.getElementsByTagName('button'));
  279. var searchClipboardButton = buttons.find(button => button.innerText === "Search Clipboard");
  280. if (searchClipboardButton) {
  281. searchClipboardButton.click();
  282. } else {
  283. alert("Make sure the Search Clipboard button is checked in the options pane.");
  284. }
  285. }, 101);
  286. }
  287. }
  288.  
  289. const activityTitleElement = document.getElementById("activity-title");
  290.  
  291. if (activityTitleElement) {
  292. const activityTitleText = activityTitleElement.textContent || activityTitleElement.innerText;
  293.  
  294. function handleAssessment() {
  295. setTimeout(() => {
  296. extractTextFromIframe();
  297. }, 250);
  298.  
  299. const iframe = window.frames[0];
  300. const iframeDocument = iframe.document;
  301.  
  302. const targetElements = iframeDocument.getElementsByClassName("Assessment_Main_Body_Content_Question");
  303.  
  304. const visibleElements = Array.from(targetElements).filter(function(element) {
  305. return element.style.display !== "none" && element.id.includes("q_");
  306. });
  307.  
  308. }
  309.  
  310. function handleAssignment() {
  311. const nestedIframeDocument = window.frames[0].frames[0].document;
  312. const contentElements = nestedIframeDocument.getElementsByClassName("content");
  313. const altElements = nestedIframeDocument.querySelectorAll('[alt]');
  314. let contentText = '';
  315.  
  316. if (contentElements.length > 0) {
  317. contentText = Array.from(contentElements)
  318. .map(element => element.innerText)
  319. .join('\n');
  320. }
  321.  
  322. const altValues = Array.from(altElements)
  323. .map(element => element.getAttribute('alt'))
  324. .join('\n');
  325.  
  326. const combinedText = contentText + (contentText && altValues ? '\n' : '') + altValues;
  327.  
  328. if (combinedText) {
  329. navigator.clipboard.writeText(combinedText)
  330. .then(() => {
  331. console.log('Content copied to clipboard!');
  332.  
  333. setTimeout(() => {
  334. clickSearchClipboard();
  335. }, 100);
  336. });
  337. }
  338. }
  339.  
  340. document.addEventListener('keydown', function(event) {
  341. if (event.key === '3') {
  342. if (activityTitleText.includes("Test") || activityTitleText.includes("Exam") || activityTitleText.includes("Quiz")) {
  343. handleAssessment();
  344. } else if (activityTitleText.includes("Assignment")) {
  345. handleAssignment();
  346. }
  347. }
  348. });
  349. }
  350.  
  351. function clickSearchClipboard() {
  352. const buttons = Array.from(document.querySelectorAll('button'));
  353. const buttonToClick = buttons.find(button => button.innerText === 'Search Clipboard');
  354. if (buttonToClick) {
  355. buttonToClick.click();
  356. } else {
  357. alert("Make sure the Search Clipboard button is checked in the options pane.");
  358. }
  359. }
  360.  
  361. function addKeyListener() {
  362. const frame = window.frames[0];
  363. const initialButtonCheck = document.getElementById('searchActionButton');
  364.  
  365. if (!window.location.href.includes("nuity")) {
  366. return;
  367. }
  368.  
  369. if (frame && !frame.keyListenerAdded) {
  370. frame.keyListenerAdded = true;
  371.  
  372. frame.document.addEventListener('keydown', function(event) {
  373. if (event.key === '3') {
  374. const activityTitleText = document.getElementById('activity-title')?.textContent || '';
  375.  
  376. if (activityTitleText.includes("Assignment")) {
  377. handleAssignment();
  378. }
  379.  
  380. if (activityTitleText.includes("Test") || activityTitleText.includes("Exam") || activityTitleText.includes("Quiz")) {
  381. handleAssessment();
  382. }
  383.  
  384. if (initialButtonCheck) {
  385. initialButtonCheck.click();
  386. }
  387. }
  388. });
  389. }
  390. }
  391.  
  392. setInterval(addKeyListener, 1000);
  393.  
  394.  
  395. function checkForButton() {
  396. const iframeDocument = window.frames[0].document;
  397. const audioEntryButton = iframeDocument.getElementById('btnEntryAudio');
  398.  
  399. if (audioEntryButton) {
  400. const existingButton = iframeDocument.getElementById('searchActionButton');
  401.  
  402. if (!existingButton) {
  403. const searchActionButton = iframeDocument.createElement('button');
  404. searchActionButton.innerText = "Search question";
  405. searchActionButton.id = "searchActionButton";
  406.  
  407. searchActionButton.style.webkitTextSizeAdjust = "100%";
  408. searchActionButton.style.borderSpacing = "0";
  409. searchActionButton.style.borderCollapse = "collapse";
  410. searchActionButton.style.fontFamily = '"Helvetica Neue", Helvetica, Arial, sans-serif';
  411. searchActionButton.style.display = "inline-block";
  412. searchActionButton.style.boxSizing = "border-box";
  413. searchActionButton.style.height = "28px";
  414. searchActionButton.style.border = "1px solid #8d8e8f";
  415. searchActionButton.style.color = "#ffffff";
  416. searchActionButton.style.fontSize = "13px";
  417. searchActionButton.style.lineHeight = "28px";
  418. searchActionButton.style.fontWeight = "bold";
  419. searchActionButton.style.textDecoration = "none";
  420. searchActionButton.style.webkitFontSmoothing = "antialiased";
  421. searchActionButton.style.whiteSpace = "nowrap";
  422. searchActionButton.style.textShadow = "0 0 5px rgba(255, 255, 255, 0.6)";
  423. searchActionButton.style.zoom = "1";
  424. searchActionButton.style.webkitBorderRadius = "3px";
  425. searchActionButton.style.backgroundColor = "#1a1a1a";
  426. searchActionButton.style.backgroundPosition = "center bottom";
  427. searchActionButton.style.backgroundSize = "100% 100%";
  428. searchActionButton.style.boxShadow = "inset 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 -1px 0 rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1)";
  429. searchActionButton.style.cursor = "pointer";
  430. searchActionButton.style.userSelect = "none";
  431. searchActionButton.style.position = "relative";
  432. searchActionButton.style.padding = "0 40px";
  433. searchActionButton.style.textAlign = "center";
  434. searchActionButton.style.margin = "0 10px";
  435.  
  436. audioEntryButton.parentElement.appendChild(searchActionButton);
  437.  
  438. searchActionButton.style.position = "absolute";
  439. searchActionButton.style.left = "50%";
  440. searchActionButton.style.transform = "translateX(-50%)";
  441.  
  442. const bottomTrayElements = iframeDocument.querySelectorAll('[class*="bottom-tray"]');
  443. bottomTrayElements.forEach(trayElement => {
  444. trayElement.style.position = 'relative';
  445. const buttonClone = searchActionButton.cloneNode(true);
  446. trayElement.appendChild(buttonClone);
  447. buttonClone.style.position = "absolute";
  448. buttonClone.style.left = "50%";
  449. buttonClone.style.transform = "translateX(-50%)";
  450. });
  451. }
  452. }
  453. }
  454. if (window.top === window.self) {
  455. const buttonCheckInterval = setInterval(checkForButton, 500);
  456. }
  457.  
  458.  
  459. const observerConfig = {
  460. attributes: false,
  461. childList: true,
  462. subtree: true
  463. };
  464.  
  465. const mutationCallback = function(mutations, observerInstance) {
  466. for (const mutation of mutations) {
  467. if (mutation.type === 'childList') {
  468. const detectedElements = document.querySelectorAll('.mark-return');
  469. if (detectedElements.length > 0) {
  470. appendSearchButton(detectedElements[0].parentNode);
  471. }
  472. }
  473. }
  474. };
  475.  
  476. const appendSearchButton = function(parentContainer) {
  477. const existingButton = document.getElementById('uniqueSearchButtonId');
  478. if (existingButton) return;
  479.  
  480. const searchActionButton = document.createElement('button');
  481. searchActionButton.innerText = "Search question";
  482. searchActionButton.id = "uniqueSearchButtonId";
  483.  
  484. searchActionButton.style.webkitTextSizeAdjust = "100%";
  485. searchActionButton.style.borderSpacing = "0";
  486. searchActionButton.style.borderCollapse = "collapse";
  487. searchActionButton.style.fontFamily = '"Helvetica Neue", Helvetica, Arial, sans-serif';
  488. searchActionButton.style.display = "inline-block";
  489. searchActionButton.style.boxSizing = "border-box";
  490. searchActionButton.style.height = "28px";
  491. searchActionButton.style.border = "1px solid #8d8e8f";
  492. searchActionButton.style.color = "#ffffff";
  493. searchActionButton.style.fontSize = "13px";
  494. searchActionButton.style.lineHeight = "28px";
  495. searchActionButton.style.fontWeight = "bold";
  496. searchActionButton.style.textDecoration = "none";
  497. searchActionButton.style.webkitFontSmoothing = "antialiased";
  498. searchActionButton.style.whiteSpace = "nowrap";
  499. searchActionButton.style.textShadow = "0 0 5px rgba(255, 255, 255, 0.6)";
  500. searchActionButton.style.zoom = "1";
  501. searchActionButton.style.webkitBorderRadius = "3px";
  502. searchActionButton.style.backgroundColor = "#1a1a1a";
  503. searchActionButton.style.backgroundPosition = "center bottom";
  504. searchActionButton.style.backgroundSize = "100% 100%";
  505. searchActionButton.style.boxShadow = "inset 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 -1px 0 rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1)";
  506. searchActionButton.style.cursor = "pointer";
  507. searchActionButton.style.userSelect = "none";
  508.  
  509. searchActionButton.style.position = "absolute";
  510. searchActionButton.style.left = "35%";
  511. searchActionButton.style.top = "50%";
  512. searchActionButton.style.transform = "translate(-70%, -50%)";
  513.  
  514. parentContainer.style.position = "relative";
  515. parentContainer.appendChild(searchActionButton);
  516. };
  517.  
  518. const targetElement = document.body;
  519.  
  520. const observerInstance = new MutationObserver(mutationCallback);
  521.  
  522. observerInstance.observe(targetElement, observerConfig);
  523.  
  524. (function() {
  525. function checkAndAddListener() {
  526. const frame = window.frames[0];
  527.  
  528. if (frame && frame.document) {
  529. const button = frame.document.getElementById("searchActionButton");
  530.  
  531. if (button) {
  532. if (!button.dataset.listenerAdded) {
  533. button.addEventListener('click', handleAssignment);
  534. button.dataset.listenerAdded = true;
  535. console.log("Listener added to the button within the iframe.");
  536. }
  537. }
  538. }
  539. }
  540. if (window.top === window.self) {
  541. setInterval(checkAndAddListener, 500);}
  542.  
  543. })();
  544.  
  545. if (window.top === window.self) {
  546. function monitorFrameForButton() {
  547. const frame = window.frames[0];
  548.  
  549. const checkInterval = setInterval(() => {
  550. if (frame && frame.document) {
  551. const button = frame.document.getElementById('uniqueSearchButtonId');
  552. if (button) {
  553. if (!frame.hasListenerAdded) {
  554. button.addEventListener('click', handleAssessment);
  555. frame.hasListenerAdded = true;
  556. console.log('Listener added to the button.');
  557.  
  558. clearInterval(checkInterval);
  559. }
  560. }
  561. }
  562. }, 100);
  563. }
  564.  
  565. monitorFrameForButton();
  566. }
  567.  
  568.  
  569. let buttonsClicked = false;
  570.  
  571. function updateTextareaAndClickButtonsOnce() {
  572. try {
  573. const iframeDoc = window.frames[0].frames[0].document;
  574.  
  575. if (iframeDoc.readyState === 'complete') {
  576. const textarea = iframeDoc.querySelector('.QuestionTextArea');
  577.  
  578. if (textarea && textarea.value.trim() === '') {
  579. const answerChoices = iframeDoc.querySelectorAll('.answer-choice-label');
  580.  
  581. let allText = '';
  582.  
  583. answerChoices.forEach(choice => {
  584. allText += choice.textContent.trim() + '\n';
  585. });
  586.  
  587. textarea.value = allText.trim();
  588.  
  589. const buttons = iframeDoc.querySelectorAll('.answer-choice-button');
  590.  
  591. buttons.forEach(button => {
  592. if (button) {
  593. button.click();
  594. } else {
  595. console.warn("Button with class 'answer-choice-button' not found.");
  596. }
  597. });
  598.  
  599. const doneButtons = iframeDoc.querySelectorAll('.done-start');
  600. setTimeout(() => {
  601. doneButtons.forEach(doneButton => {
  602. if (doneButton) {
  603. doneButton.click();
  604. } else {
  605. console.warn("Button with class 'done-start' not found.");
  606. }
  607. });
  608.  
  609. const retryButtons = iframeDoc.querySelectorAll('.done-retry');
  610. setTimeout(() => {
  611. retryButtons.forEach(retryButton => {
  612. if (retryButton) {
  613. retryButton.click();
  614. } else {
  615. console.warn("Button with class 'done-retry' not found.");
  616. }
  617. });
  618. },400);
  619. }, 200);
  620. }
  621. }
  622. } catch (error) {
  623. console.error("An error occurred:", error);
  624. }
  625. }
  626. function checkUpdateTextareaAndClickButtonsOnce() {
  627. const isAutoWritingChecked = document.getElementById('autoWritingCheckbox').checked;
  628. const element = document.getElementById('activity-title');
  629.  
  630. const isAssignmentTitle = element && element.textContent.includes("Assignment");
  631.  
  632. const isAutoWritingOnAssignmentChecked = isAssignmentTitle
  633. ? document.getElementById('autoWritingOnAssignmentCheckbox').checked
  634. : true;
  635.  
  636. if (isAutoWritingChecked && (isAssignmentTitle ? isAutoWritingOnAssignmentChecked : true)) {
  637. updateTextareaAndClickButtonsOnce();
  638. }
  639. }
  640. if (window.top === window.self) {
  641. setInterval(checkUpdateTextareaAndClickButtonsOnce, 1000);}
  642.  
  643.  
  644.  
  645. function checkOpacity() {
  646. if (frames[0] && frames[0].document) {
  647. var homeVideoContainer = frames[0].document.getElementById("home_video_container");
  648. if (homeVideoContainer && homeVideoContainer.parentNode.style.opacity == 1) {
  649. } else {
  650. try {
  651. if (document.getElementById("activity-title").innerText == "Assignment") {}
  652. if (["Instruction", "Summary", "Warm-Up"].includes(document.getElementById("activity-title").innerText)) {
  653. try {
  654. clickFootnavAndNextFrame();
  655. window.options = window.frames[0].frames[0].document.getElementsByClassName("answer-choice-button");
  656. window.options[Math.floor(Math.random() * window.options.length)].click();
  657. } catch (TypeError) {}
  658. try {
  659. window.frames[0].API.Frame.check();
  660. } catch (TypeError) {}
  661. }
  662. } catch (TypeError) {}
  663. }
  664. }
  665. }
  666.  
  667. function checkcheckOpacity() {
  668. const isGuessingChecked = document.getElementById('guessingCheckbox').checked;
  669. if (isGuessingChecked) {
  670. checkOpacity();
  671. }
  672. }
  673. if (window.top === window.self) {
  674. setInterval(checkcheckOpacity, 1000);}
  675.  
  676.  
  677.  
  678. setInterval(function() {
  679. var element = document.getElementById("invis-o-div");
  680. if (element) {
  681. element.remove();
  682. }
  683. }, 1000);
  684.  
  685.  
  686.  
  687. function clickFootnavAndNextFrame() {
  688. try {
  689. document.getElementsByClassName("footnav goRight")[0].click();
  690. } catch (TypeError) {}
  691.  
  692. try {
  693. window.frames[0].API.FrameChain.nextFrame();
  694. } catch (TypeError) {}
  695. }
  696.  
  697.  
  698.  
  699. var clipboardButton;
  700.  
  701. function createClipboardSearchButton() {
  702. try {
  703. var iframe = document.querySelector("iframe");
  704. if (iframe) {
  705. var rect = iframe.getBoundingClientRect();
  706. var iframeTop = rect.top + window.scrollY;
  707. var iframeRight = rect.right + window.scrollX;
  708.  
  709. var buttonContainer = document.createElement('div');
  710. buttonContainer.style.position = 'fixed';
  711. buttonContainer.style.top = (iframeTop + 10) + 'px';
  712. buttonContainer.style.left = (iframeRight - 150) + 'px';
  713. buttonContainer.style.zIndex = '9999';
  714. document.body.appendChild(buttonContainer);
  715.  
  716. clipboardButton = document.createElement('button');
  717. clipboardButton.innerText = 'Search Clipboard';
  718. buttonContainer.appendChild(clipboardButton);
  719. }
  720. } catch (error) {
  721. console.error('Error accessing the first iframe:', error);
  722. }
  723. }
  724.  
  725. function checkClipboardSearchButton() {
  726. const isClipboardChecked = document.getElementById('searchClipboardCheckbox').checked;
  727.  
  728. if (isClipboardChecked) {
  729. if (!clipboardButton) {
  730. createClipboardSearchButton();
  731. }
  732. } else {
  733. if (clipboardButton) {
  734. clipboardButton.parentElement.removeChild(clipboardButton);
  735. clipboardButton = null;
  736. }
  737. }
  738. }
  739. if (window.top === window.self) {
  740. setInterval(checkClipboardSearchButton, 1000);}
  741.  
  742.  
  743. document.addEventListener('click', function(event) {
  744. if (event.target.tagName === 'BUTTON' && event.target.innerText.includes('Clipboard')) {
  745. navigator.clipboard.readText().then(function(clipboardText) {
  746. if (clipboardText) {
  747. var isBrainlyChecked = document.getElementById('searchInBrainlyCheckbox').checked;
  748. var searchUrl = 'https://brainly.com/app/ask?entry=top&q=' + encodeURIComponent(clipboardText);
  749.  
  750. if (isBrainlyChecked) {
  751. var brainlyIframe = document.getElementById('brainly-chat-iframe');
  752. if (brainlyIframe) {
  753. brainlyIframe.src = searchUrl;
  754. }
  755. } else {
  756. window.open(searchUrl, '_blank');
  757. }
  758. }
  759. }).catch(function(err) {
  760. console.error('Failed to read clipboard contents: ', err);
  761. });
  762. }
  763. });
  764.  
  765. function addDeepaiIframes() {
  766. const wrapElement = document.getElementById('wrap');
  767.  
  768. if (!document.getElementById('deepai-chat-iframe')) {
  769. const deepaiIframe = document.createElement('iframe');
  770. deepaiIframe.id = 'deepai-chat-iframe';
  771. deepaiIframe.src = 'https://deepai.org/chat';
  772.  
  773. deepaiIframe.style.width = '25%';
  774. deepaiIframe.style.height = '100vh';
  775. deepaiIframe.style.border = 'none';
  776. deepaiIframe.style.position = 'absolute';
  777. deepaiIframe.style.top = '0';
  778. deepaiIframe.style.right = '0';
  779. deepaiIframe.style.zIndex = '20000';
  780. wrapElement.style.position = 'relative';
  781. deepaiIframe.style.opacity = '0';
  782. deepaiIframe.style.transition = 'opacity 0.5s';
  783. deepaiIframe.sandbox = 'allow-same-origin allow-scripts';
  784.  
  785. document.body.appendChild(deepaiIframe);
  786. }
  787. }
  788.  
  789. function addBrainlyIframes() {
  790. const wrapElement = document.getElementById('wrap');
  791.  
  792. if (!document.getElementById('brainly-chat-iframe')) {
  793. const brainlyIframe = document.createElement('iframe');
  794. brainlyIframe.id = 'brainly-chat-iframe';
  795. brainlyIframe.src = 'https://brainly.com/search';
  796.  
  797. brainlyIframe.style.width = '25%';
  798. brainlyIframe.style.height = '100vh';
  799. brainlyIframe.style.border = 'none';
  800. brainlyIframe.style.position = 'absolute';
  801. brainlyIframe.style.top = '0';
  802. brainlyIframe.style.left = '0';
  803. brainlyIframe.style.zIndex = '20000';
  804. wrapElement.style.position = 'relative';
  805. brainlyIframe.style.opacity = '0';
  806. brainlyIframe.style.transition = 'opacity 0.5s';
  807. brainlyIframe.sandbox = 'allow-same-origin allow-scripts';
  808.  
  809. document.body.appendChild(brainlyIframe);
  810. }
  811. }
  812.  
  813. addDeepaiIframes();
  814. addBrainlyIframes();
  815.  
  816. function updateDeepaiIframeVisibility() {
  817. const deepaiIframe = document.getElementById('deepai-chat-iframe');
  818. const isAiChatChecked = document.getElementById('aiChatCheckbox').checked;
  819.  
  820. if (deepaiIframe) {
  821. if (isAiChatChecked) {
  822. deepaiIframe.style.opacity = '1';
  823. deepaiIframe.style.display = 'block';
  824. } else {
  825. deepaiIframe.style.opacity = '0';
  826. setTimeout(() => deepaiIframe.style.display = 'none', 500);
  827. }
  828. }
  829. }
  830.  
  831. function updateBrainlyIframeVisibility() {
  832. const brainlyIframe = document.getElementById('brainly-chat-iframe');
  833. const isBrainlyChecked = document.getElementById('searchInBrainlyCheckbox').checked;
  834.  
  835. if (brainlyIframe) {
  836. if (isBrainlyChecked) {
  837. brainlyIframe.style.opacity = '1';
  838. brainlyIframe.style.display = 'block';
  839. } else {
  840. brainlyIframe.style.opacity = '0';
  841. setTimeout(() => brainlyIframe.style.display = 'none', 500);
  842. }
  843. }
  844. }
  845.  
  846. setInterval(() => {
  847. updateDeepaiIframeVisibility();
  848. updateBrainlyIframeVisibility();
  849. }, 1000);
  850.  
  851. function createButtonAndPane() {
  852. if (document.querySelector('#tweaksButton')) return;
  853.  
  854. const mainFootDiv = document.querySelector('.mainfoot');
  855.  
  856. const toggleButton = document.createElement('button');
  857. toggleButton.id = 'tweaksButton';
  858. toggleButton.textContent = 'Toggle Options';
  859.  
  860. toggleButton.style.border = "1px solid #5f5f5f";
  861. toggleButton.style.boxShadow = "inset 0 0 5px rgba(0, 0, 0, 0.6)";
  862. toggleButton.style.backgroundColor = "rgb(39, 39, 39)";
  863. toggleButton.style.color = "#f9a619";
  864. toggleButton.style.borderRadius = "3px";
  865. toggleButton.style.marginLeft = "40%";
  866. toggleButton.style.zIndex = "2";
  867. toggleButton.style.padding = '5px 10px';
  868.  
  869. mainFootDiv.appendChild(toggleButton);
  870.  
  871. if (!window.pane) {
  872. window.pane = document.createElement('div');
  873. window.pane.style.display = 'none';
  874. document.body.appendChild(window.pane);
  875.  
  876. const popupMenu = document.createElement('div');
  877. popupMenu.className = 'popup-menu';
  878.  
  879. const aiChatItem = createMenuItem('AI Chat', 'aiChatCheckbox');
  880. popupMenu.appendChild(aiChatItem);
  881.  
  882. const searchInBrainlyItem = createMenuItem('Search in Brainly frame', 'searchInBrainlyCheckbox');
  883. popupMenu.appendChild(searchInBrainlyItem);
  884.  
  885. const autoVocabItem = createMenuItem('Auto Vocab', 'autoVocabCheckbox');
  886. popupMenu.appendChild(autoVocabItem);
  887.  
  888. const autoWritingItem = createMenuItem('Auto Writing', 'autoWritingCheckbox');
  889. popupMenu.appendChild(autoWritingItem);
  890.  
  891. const autoplayItem = createMenuItem('Autoplay', 'autoplayCheckbox');
  892. popupMenu.appendChild(autoplayItem);
  893.  
  894. const searchClipboardItem = createMenuItem('Search Clipboard Button', 'searchClipboardCheckbox');
  895. popupMenu.appendChild(searchClipboardItem);
  896.  
  897. const guessingItem = createMenuItem('Guessing', 'guessingCheckbox');
  898. popupMenu.appendChild(guessingItem);
  899.  
  900. const autoWritingOnAssignmentItem = createMenuItem('AutoWriting On Assignment', 'autoWritingOnAssignmentCheckbox');
  901. popupMenu.appendChild(autoWritingOnAssignmentItem);
  902.  
  903. window.pane.appendChild(popupMenu);
  904.  
  905. const footerText = document.createElement('div');
  906. footerText.style.marginTop = '20px';
  907. footerText.style.color = 'rgb(249, 166, 25)';
  908. footerText.style.textAlign = "center";
  909. footerText.textContent = "This was made by me, TallTacoTristan, as a way to make edge-nuity " +
  910. "classes MUCH easier and skip by the tedious bits but it took a long time, probably over " +
  911. "24 hours of just coding, to write over half a thousand lines, it has many features, " +
  912. "the ones above are less than half, just the ones that need a toggle. " +
  913. "So please leave a good review on my page for all the time I spent to save yours, Thank you.";
  914.  
  915. const discordMessage = document.createElement('div');
  916. discordMessage.textContent = "Join this discord if you have any issues, questions, or suggestions!.";
  917. discordMessage.style.marginTop = '10px';
  918.  
  919. const discordLink = document.createElement('a');
  920. discordLink.textContent = "https://discord.gg/6qJwkYSmrQ";
  921. discordLink.href = "https://discord.gg/6qJwkYSmrQ";
  922. discordLink.target = "_blank";
  923. discordLink.style.marginTop = '5px';
  924. discordLink.style.color = 'cyan';
  925. discordLink.style.textDecoration = 'underline';
  926.  
  927. footerText.appendChild(discordMessage);
  928. footerText.appendChild(discordLink);
  929.  
  930. window.pane.appendChild(footerText);
  931.  
  932.  
  933. loadCheckboxState('aiChat', 'aiChatCheckbox');
  934. loadCheckboxState('searchInBrainly', 'searchInBrainlyCheckbox');
  935. loadCheckboxState('autoVocab', 'autoVocabCheckbox');
  936. loadCheckboxState('autoWriting', 'autoWritingCheckbox');
  937. loadCheckboxState('autoplay', 'autoplayCheckbox');
  938. loadCheckboxState('searchClipboard', 'searchClipboardCheckbox');
  939. loadCheckboxState('guessing', 'guessingCheckbox');
  940. loadCheckboxState('autoWritingOnAssignment', 'autoWritingOnAssignmentCheckbox');
  941.  
  942. makeDraggable(window.pane);
  943. }
  944.  
  945. toggleButton.addEventListener('click', function() {
  946. console.log('Button clicked! Toggling pane visibility.');
  947.  
  948. if (window.pane.style.display === 'none' || window.pane.style.display === '') {
  949. window.pane.style.width = "50%";
  950. window.pane.style.height = "auto";
  951. window.pane.style.position = "absolute";
  952. window.pane.style.marginTop = "20vh";
  953. window.pane.style.marginLeft = "25%";
  954. window.pane.style.border = "1px solid rgb(95, 95, 95)";
  955. window.pane.style.borderRadius = "3px";
  956. window.pane.style.backgroundColor = "rgb(39, 39, 39)";
  957. window.pane.style.overflow = "hidden";
  958. window.pane.style.color = "rgb(249, 166, 25)";
  959. window.pane.style.textAlign = "center";
  960. window.pane.style.overflowY = "scroll";
  961. window.pane.style.display = 'block';
  962.  
  963. checkCheckboxState('aiChatCheckbox');
  964. checkCheckboxState('searchInBrainlyCheckbox');
  965. checkCheckboxState('autoVocabCheckbox');
  966. checkCheckboxState('autoWritingCheckbox');
  967. checkCheckboxState('autoplayCheckbox');
  968. checkCheckboxState('searchClipboardCheckbox');
  969. checkCheckboxState('guessingCheckbox');
  970. checkCheckboxState('autoWritingOnAssignmentCheckbox');
  971. } else {
  972. window.pane.style.display = 'none';
  973. }
  974. });
  975. }
  976. function makeDraggable(element) {
  977. let offsetX, offsetY;
  978.  
  979. element.addEventListener('mousedown', function(e) {
  980. e.preventDefault();
  981. offsetX = e.clientX - element.getBoundingClientRect().left + element.offsetWidth / 2;
  982. offsetY = e.clientY - element.getBoundingClientRect().top + element.offsetHeight / 2;
  983. element.classList.add('dragging');
  984.  
  985. document.addEventListener('mousemove', dragElement);
  986. document.addEventListener('mouseup', stopDragging);
  987. });
  988.  
  989. function dragElement(e) {
  990. e.preventDefault();
  991. let x = e.clientX - offsetX;
  992. let y = e.clientY - offsetY;
  993.  
  994. element.style.left = x + 'px';
  995. element.style.top = y + 'px';
  996. }
  997.  
  998. function stopDragging() {
  999. element.classList.remove('dragging');
  1000. document.removeEventListener('mousemove', dragElement);
  1001. document.removeEventListener('mouseup', stopDragging);
  1002. }
  1003. }
  1004. function createMenuItem(text, checkboxId) {
  1005. const itemDiv = document.createElement('div');
  1006. itemDiv.className = 'menu-item';
  1007.  
  1008. const checkbox = document.createElement('input');
  1009. checkbox.type = 'checkbox';
  1010. checkbox.id = checkboxId;
  1011.  
  1012. const storedValue = localStorage.getItem(checkboxId);
  1013. if (storedValue !== null) {
  1014. checkbox.checked = (storedValue === 'true');
  1015. }
  1016.  
  1017. const label = document.createElement('label');
  1018. label.innerText = text;
  1019. label.setAttribute('for', checkboxId);
  1020.  
  1021. itemDiv.appendChild(checkbox);
  1022. itemDiv.appendChild(label);
  1023.  
  1024. checkbox.addEventListener('change', () => {
  1025. console.log(`${text} checkbox is now ${checkbox.checked ? 'checked' : 'unchecked'}`);
  1026. localStorage.setItem(checkboxId, checkbox.checked);
  1027. });
  1028.  
  1029. return itemDiv;
  1030. }
  1031.  
  1032. function loadCheckboxState(checkboxId) {
  1033. const storedValue = localStorage.getItem(checkboxId);
  1034. if (storedValue !== null) {
  1035. const checkbox = document.getElementById(checkboxId);
  1036. if (checkbox) {
  1037. checkbox.checked = (storedValue === 'true');
  1038. }
  1039. }
  1040. }
  1041.  
  1042. function checkCheckboxState(checkboxId) {
  1043. const checkbox = document.getElementById(checkboxId);
  1044. const storedValue = localStorage.getItem(checkboxId);
  1045.  
  1046. if (storedValue !== null && checkbox) {
  1047. if (checkbox.checked !== (storedValue === 'true')) {
  1048. checkbox.checked = (storedValue === 'true');
  1049. }
  1050. }
  1051. }
  1052. if (window.top === window.self) {
  1053. setInterval(createButtonAndPane, 1000);}
  1054.  
  1055.  
  1056.  
  1057. var checkbox = document.getElementById('searchInBrainlyCheckbox');
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063. let lastTitle = '';
  1064.  
  1065. function checkForAssignment() {
  1066. const element = document.getElementById('activity-title');
  1067. if (element) {
  1068. const currentTitle = element.textContent || element.innerText;
  1069.  
  1070. const excludedKeywords = [
  1071. "Summary", "Warm-Up", "Instruction", "Quiz",
  1072. "Assignment", "Unit Test",
  1073. "Unit Review", "Cumulative Exam Review",
  1074. "Vocab","Cumulative Exam"
  1075. ];
  1076.  
  1077. const containsExcludedKeyword = excludedKeywords.some(keyword => currentTitle.includes(keyword));
  1078. const currentContainsAssignment = currentTitle.includes("Assignment");
  1079.  
  1080. if (currentTitle !== lastTitle) {
  1081. if (currentContainsAssignment || !containsExcludedKeyword) {
  1082. new Notification("Done!");
  1083. }
  1084. lastTitle = currentTitle;
  1085. }
  1086. }
  1087. }if (window.top === window.self) {
  1088. setInterval(checkForAssignment, 1000);}
  1089.  
  1090. const isAutoVocabChecked = document.getElementById('autoVocabCheckbox').checked;
  1091.  
  1092.  
  1093. function clickNextButtonIfVocabulary() {
  1094. if (document.getElementById("activity-title").innerText === "Vocabulary") {
  1095. const nextButton = window.frames[0].document.getElementsByClassName("uibtn uibtn-blue uibtn-arrow-next")[0];
  1096. if (nextButton) {
  1097. nextButton.click();
  1098. console.log("Clicked next button");
  1099. } else {
  1100. console.log("Next button not found");
  1101. }
  1102. }
  1103. }
  1104.  
  1105. function vocabCompleter() {
  1106. if (document.getElementById("activity-title").innerText === "Vocabulary") {
  1107. var i = 0;
  1108. try {
  1109. var txt = window.frames[0].document.getElementsByClassName("word-background")[0].value;
  1110. window.frames[0].document.getElementsByClassName("word-textbox")[0].value = txt;
  1111. var event = new Event("keyup");
  1112. window.frames[0].document.getElementsByClassName("word-textbox word-normal")[0].dispatchEvent(event);
  1113. } catch (e) {
  1114. console.error(e);
  1115. return;
  1116. }
  1117.  
  1118. var speed = 50;
  1119. var output = "Vocab Completer, ";
  1120.  
  1121. window.frames[0].document.getElementsByClassName("playbutton vocab-play")[0].click();
  1122. window.frames[0].document.getElementsByClassName("playbutton vocab-play")[1].click();
  1123.  
  1124. }
  1125. }
  1126.  
  1127. function checkAndExecuteFunctions() {
  1128. const isAutoVocabChecked = document.getElementById('autoVocabCheckbox').checked;
  1129. if (isAutoVocabChecked) {
  1130. clickNextButtonIfVocabulary();
  1131. vocabCompleter();
  1132. }
  1133. }
  1134. if (window.top === window.self) {
  1135. setInterval(checkAndExecuteFunctions, 1000);}
  1136.  
  1137.  
  1138. if (window.top === window.self) {
  1139. setInterval(() => {
  1140. const activityTitle = document.getElementById("activity-title").innerText;
  1141. const homeVideoContainer = document.querySelector('.home-video-container');
  1142. const shouldClick = !(
  1143. homeVideoContainer &&
  1144. homeVideoContainer.parentNode.style.opacity == "1"
  1145. );
  1146.  
  1147. if (shouldClick && !["Assignment", "Quiz"].includes(activityTitle)) {
  1148. const goRightButton = document.querySelector(".FrameRight");
  1149. if (goRightButton) {
  1150. goRightButton.onclick();
  1151. }
  1152. const iconButton = document.querySelector(".nav-icon[data-bind='realEnable: $root.stageView().nextEnabled']");
  1153. if (iconButton) {
  1154. iconButton.click();
  1155. }
  1156. }
  1157. }, 1000);}
  1158.