Advertisement
Guest User

Edgentweaks

a guest
Mar 14th, 2021
6,761
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.91 KB | None | 0 0
  1. // ==UserScript==
  2. // @name EdgenTweaks
  3. // @namespace https://gradyn.com/
  4. // @version 1.2.9
  5. // @description Adds tweaks to edgenuity [IMPORTANT NOTE: Edgentweaks is not created by, sponsored by, affiliated with, endorsed by, or otherwise assosiated with Edgenuity Inc]
  6. // @author Gradyn Wursten
  7. // @match *://*.core.learn.edgenuity.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13. window.configElements = []
  14. //==BEGIN UI BUILDING==
  15. window.overlay = document.createElement("div")
  16. window.overlay.style.width = "100vw"
  17. window.overlay.style.height = "100vh"
  18. window.overlay.style.zIndex = "1"
  19. window.overlay.style.position = "fixed"
  20. window.overlay.style.visibility = "hidden"
  21. window.overlay.id = "overlay"
  22. document.body.prepend(window.overlay)
  23. function BuildMenuEntry (name, info, id, configpane) {
  24. window.entry = document.createElement("div")
  25. window.tickbox = document.createElement("input")
  26. window.tickbox.type = "checkbox"
  27. window.tickbox.id = id
  28. window.configElements.push(id)
  29. window.entry.appendChild(window.tickbox)
  30. window.window.label = document.createElement("label")
  31. window.label.innerText = name
  32. window.entry.appendChild(window.label)
  33. if (configpane != undefined) {
  34. window.configbutton = document.createElement("button")
  35. window.configbutton.innerText = "Configure"
  36. window.configbutton.style.marginLeft = "7px"
  37. window.configbutton.style.border = "1px solid #5f5f5f"
  38. window.configbutton.style.boxShadow = "inset 0 0 5px rgba(0, 0, 0, 0.6)"
  39. window.configbutton.style.backgroundColor = "rgb(39, 39, 39)"
  40. window.configbutton.style.color = "#f9a619"
  41. window.configbutton.style.borderRadius = "3px"
  42. window.configbutton.onclick = function () {
  43. if (document.getElementById(configpane).style.visibility == "unset") {
  44. document.getElementById(configpane).style.visibility = "hidden"
  45. } else {
  46. document.getElementById(configpane).style.visibility = "unset"
  47. }
  48. }
  49. window.entry.appendChild(window.configbutton)
  50. }
  51. window.desc = document.createElement("p")
  52. window.desc.innerHTML = info;
  53. window.entry.appendChild(window.desc)
  54. return window.entry
  55. }
  56. function RenderPane(name, id, width, height, margintop, marginleft) {
  57. window.pane = document.createElement("div")
  58. window.pane.style.width = width
  59. window.pane.style.height = height
  60. window.pane.style.position = "absolute"
  61. window.pane.style.marginTop = margintop
  62. window.pane.style.marginLeft = marginleft
  63. window.pane.style.border = "1px solid rgb(95, 95, 95)"
  64. window.pane.style.borderRadius = "3px"
  65. window.pane.style.backgroundColor = "rgb(39, 39, 39)"
  66. window.pane.style.overflow = "hidden"
  67. window.pane.style.color = "rgb(249, 166, 25)"
  68. window.pane.style.textAlign = "center"
  69. window.pane.style.overflowY = "scroll"
  70. window.pane.id = id
  71. window.panetitle = document.createElement("h1")
  72. window.panetitle.innerText = name
  73. window.pane.appendChild(window.panetitle)
  74. window.pane.appendChild(document.createElement("hr"))
  75. document.getElementById("overlay").appendChild(window.pane)
  76. }
  77. // Add the button
  78. window.tweaksbutton = document.createElement("button")
  79. window.tweaksbutton.innerText = "Tweaks"
  80. window.tweaksbutton.id = "tweaksbutton"
  81. window.tweaksbutton.style.border = "1px solid #5f5f5f"
  82. window.tweaksbutton.style.boxShadow = "inset 0 0 5px rgba(0, 0, 0, 0.6)"
  83. window.tweaksbutton.style.backgroundColor = "rgb(39, 39, 39)"
  84. window.tweaksbutton.style.color = "#f9a619"
  85. window.tweaksbutton.style.borderRadius = "3px"
  86. window.tweaksbutton.style.marginLeft = "40%"
  87. window.tweaksbutton.style.zIndex = "2"
  88.  
  89. document.getElementsByClassName("mainfoot")[0].appendChild(window.tweaksbutton)
  90. // Build main menu
  91. RenderPane("EdgenTweaks", "tweaksmenu", "50%", "50%", "20vh", "25%")
  92. // Menu Entrys
  93. document.getElementById("tweaksmenu").appendChild(BuildMenuEntry("Auto Advance", "Advance to the next portion of the course automatically when it becomes available", "AutoAdvance.tickbox"))
  94. document.getElementById("tweaksmenu").appendChild(BuildMenuEntry("Auto Complete Vocab","Automatically completes vocab assignments","AutoCompleteVocabTickbox"))
  95. /* document.getElementById("tweaksmenu").appendChild(BuildMenuEntry("Skip Videos", "Skips videos. <span style='color: red'>THIS IS HIGHLY EXPERIMENTAL AND WILL BREAK THINGS</span>", "SkipVideosTickbox")) */
  96. document.getElementById("tweaksmenu").appendChild(BuildMenuEntry("Skip intro", "Lets you interact with practices while the intro audio is playing", "SkipIntro.tickbox"))
  97. document.getElementById("tweaksmenu").appendChild(BuildMenuEntry("Guess Practice", "Most teachers don't count practices twords your final grade, so you can guess your way thru them. This automatically guesses thru practices.", "GuessPractice.tickbox", "practiceconfig"))
  98. document.getElementById("tweaksmenu").appendChild(BuildMenuEntry("Show Columns","On practices where you have to write a text response to a prompt, there is an example response to the prompt. However, it is hidden until you submit your response. This forces it to show even if you haven't submitted a response yet", "ShowColumn.tickbox"))
  99. // Config Menus
  100. RenderPane("Guess Practice Config", "practiceconfig", "15%", "15%", "0", "0")
  101. document.getElementById("practiceconfig").style.visibility = "hidden"
  102. document.getElementById("practiceconfig").appendChild(BuildMenuEntry("Guess thru Assignments", "Guesses thru assignments. This is highly discouraged", "guessassignments"))
  103. // window.copyright
  104. window.copyright = document.createElement("p")
  105. window.copyright.innerHTML = "EdgenTweaks Version 1.2.9 by Gradyn Wursten (<a href='https://host.gradyn.com/edgentweaks/support.html'>Support the project!</a>)"
  106. window.copyright.style.color = "gray"
  107. window.copyright.style.width = "100%"
  108. document.getElementById("tweaksmenu").append(window.copyright)
  109. // Activate the button
  110. document.getElementById("tweaksbutton").addEventListener("click", function () {
  111. if (document.getElementById("overlay").style.visibility == "hidden") {
  112. document.getElementById("overlay").style.visibility = "visible"
  113. } else {
  114. document.getElementById("overlay").style.visibility = "hidden"
  115. }
  116. })
  117.  
  118.  
  119. //==BEGIN TWEAKS==
  120. // Auto Advance
  121. function autoadvance () {
  122. if (document.getElementById("AutoAdvance.tickbox").checked) {
  123. if (document.getElementById("activity-title").innerText == "Quiz") {
  124. } else {
  125. try {document.getElementsByClassName("footnav goRight")[0].click()} catch (TypeError) {}
  126. try {window.frames[0].API.FrameChain.nextFrame()} catch (TypeError) {}
  127. }
  128. }
  129. }
  130. // Skip intro
  131. function skipIntro() {
  132. if (document.getElementById("SkipIntro.tickbox").checked) {
  133. try {window.frames[0].document.getElementById("invis-o-div").remove()} catch (TypeError) {}
  134. }
  135. }
  136. // Guess Practice
  137. function GuessPractice() {
  138. if (document.getElementById("GuessPractice.tickbox").checked) {
  139. try { // document.getElementById("activity-title") may error
  140. if (document.getElementById("activity-title").innerText == "Assignment") {
  141. if (!document.getElementById("guessassignments").checked) {
  142. return // End the method call so we dont guess
  143. }
  144. }
  145. if (["Instruction", "Assignment", "Warm-Up"].includes(document.getElementById("activity-title").innerText)) {
  146. try {window.options = window.frames[0].frames[0].document.getElementsByClassName("answer-choice-button");
  147. window.options[Math.floor(Math.random() * window.options.length)].click();} catch (TypeError) {}
  148. try {window.frames[0].API.Frame.check()} catch (TypeError) {} // This has to be seporate from the option clicker in case it's a text only practice
  149. }
  150. }
  151. catch (TypeError) {}
  152. }
  153. }
  154. // Unhide Right Column
  155. function showColumn() {
  156. if (document.getElementById("ShowColumn.tickbox").checked) {
  157. try {window.frames[0].frames[0].document.getElementsByClassName("right-column")[0].children[0].style.display = "block"} catch (TypeError) {}
  158. try {window.frames[0].frames[0].document.getElementsByClassName("left-column")[0].children[0].style.display = "block"} catch (TypeError) {}
  159. }
  160. }
  161. // Skip videos (PATCHED)
  162. /* function skipVideo() {
  163. if (document.getElementById("SkipVideosTickbox").checked) {
  164. if (document.getElementById("activity-title").innerText != "Assignment") { // Appearantly this causes problems with assignments, disable it for now
  165. if (frames[0].document.getElementById("home_video_container").parentNode.style.opacity == 1) {
  166. try {window.frames[0].API.FrameChain.framesStatus[window.frames[0].API.FrameChain.currentFrame - 1] = "complete"} catch(TypeError) {}
  167. }
  168. }
  169. }
  170. } */
  171. // Auto complete vocab
  172. function vocabCompleter() {
  173. if (document.getElementById("AutoCompleteVocabTickbox").checked) {
  174. if (document.getElementById("activity-title").innerText == "Vocabulary"){
  175. try {window.frames[0].document.getElementsByClassName("word-textbox")[0].value = window.frames[0].document.getElementsByClassName("word-background")[0].value} catch(TypeError) {}
  176. try {for (var x of window.frames[0].document.getElementsByClassName("playbutton vocab-play")) {
  177. x.click()
  178. }} catch (TypeError) {}
  179. try {window.frames[0].document.getElementsByClassName("uibtn uibtn-blue uibtn-arrow-next")[0].click()} catch(TypeError) {}
  180. }
  181. }
  182. }
  183.  
  184. //==BEGIN CONFIG==
  185. function loaditem (item, id) {
  186. if (localStorage.getItem(item) != null) {
  187. if (localStorage.getItem(item) == "true") { //Because LocalStorage only stores strings
  188. document.getElementById(id).checked = true
  189. } else {
  190. document.getElementById(id).checked = false
  191. }
  192. }
  193. }
  194. // Load config
  195. for (var x of configElements) {
  196. loaditem(x, x)
  197. }
  198. // Sync Config
  199. function syncConfig() {
  200. for (var x of configElements) {
  201. localStorage.setItem(x, document.getElementById(x).checked.toString())
  202. }
  203. }
  204. // Easter Egg
  205. window.menutitleclicks = 0
  206. function easteregg() {
  207. if (window.menutitleclicks < 10) {
  208. window.menutitleclicks++
  209. if (window.menutitleclicks == 10) {
  210. console.log("Easter egg activated")
  211. var easteregg = document.createElement("img")
  212. easteregg.src = "https://i.gifer.com/zYw.gif"
  213. easteregg.style.position = "fixed"
  214. easteregg.style.bottom = "40px";
  215. easteregg.style.marginLeft = "80%"
  216. document.body.appendChild(easteregg)
  217. }
  218. }
  219. }
  220. document.getElementById("tweaksmenu").firstChild.onclick = easteregg
  221. // Master loop
  222. function loop () {
  223. vocabCompleter()
  224. autoadvance()
  225. skipIntro()
  226. GuessPractice()
  227. syncConfig()
  228. showColumn()
  229. // skipVideo()
  230. }
  231. window.masterloop = setInterval(loop, 1000);
  232. })();
  233.  
  234.  
  235.  
  236.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement