Advertisement
cevoj35548

EdgenLeaks - Userscript for leaked Edgenuity answers

May 27th, 2023 (edited)
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         EdgenLeak
  3. // @namespace    https://edgenuity.com
  4. // @version      1.0
  5. // @description  Reveals the answer for tests
  6. // @author       Databones
  7. // @match        *://*.core.learn.edgenuity.com/*
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. // Original guy took it down after just a few hours
  12.  
  13. console.log("Starting script execution");
  14.  
  15. // Display answer choice IDs next to the answer labels.
  16. function displayAnswerChoiceIDs() {
  17.     console.log("Starting displayAnswerChoiceIDs");
  18.  
  19.     const answerChoiceLabels = document.querySelectorAll(".answer-choice-label[for]");
  20.  
  21.     fetch('https://codeberg.org/kuwow112/edgenf/raw/branch/main/data.txt')
  22.         .then(response => {
  23.             if (!response.ok) {
  24.                 throw new Error("Network response was not ok");
  25.             }
  26.             return response.text();
  27.         })
  28.         .then(answerIDs => {
  29.             console.log("Fetch completed successfully");
  30.  
  31.             let duplicateCounter = 0; // Counter for duplicate modifications
  32.  
  33.             answerChoiceLabels.forEach(answerChoiceLabel => {
  34.                 const labelFor = answerChoiceLabel.getAttribute("for").trim();
  35.                 if (answerIDs.includes(labelFor)) {
  36.                     const existingSpan = answerChoiceLabel.querySelector(".answer-choice-id");
  37.                     if (!existingSpan) {
  38.                         const spanNode = document.createElement("span");
  39.                         spanNode.className = "answer-choice-id";
  40.                         spanNode.style.cssText = "font-size: smaller; display: block; color: green;";
  41.                         spanNode.textContent = labelFor;
  42.                         answerChoiceLabel.appendChild(document.createElement("br"));
  43.                         answerChoiceLabel.appendChild(spanNode);
  44.                     } else {
  45.                         duplicateCounter++;
  46.                         if (duplicateCounter > 6969) {
  47.                             console.log("Reached maximum duplicate modifications, disconnecting observer");
  48.                             observer.disconnect();
  49.                         }
  50.                     }
  51.                 }
  52.             });
  53.  
  54.             console.log("Displaying answer choice IDs");
  55.         })
  56.         .catch(error => {
  57.             console.error("An error occurred during the fetch request:", error);
  58.         });
  59. }
  60.  
  61. console.log("Calling displayAnswerChoiceIDs");
  62. displayAnswerChoiceIDs();
  63.  
  64. // Observe changes to the document and reapply modifications
  65. const observer = new MutationObserver(mutationsList => {
  66.     for (const mutation of mutationsList) {
  67.         if (mutation.type === "childList") {
  68.             console.log("DOM changed, reapplying modifications");
  69.             displayAnswerChoiceIDs();
  70.             break;
  71.         }
  72.     }
  73. });
  74.  
  75. observer.observe(document.body, {
  76.     childList: true,
  77.     subtree: true
  78. });
  79.  
  80. console.log("Script execution completed");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement