Krakdemy

ModMenu para khan academy

  1. // ==UserScript==
  2. // @name Krakdemy
  3. // @grant none
  4. // @namespace https://greasyfork.org/pt-BR/users/1346771-kinjinho
  5. // @match https://pt.khanacademy.org/*
  6. // @license MIT
  7. // @version 3.0 Remake
  8. // @author KIN
  9. // @description ModMenu para khan academy
  10. // @patch kd12m8a24h15M53
  11. // ==/UserScript==
  12.  
  13.  
  14. (function () {
  15. let overlayHTML = ` <link rel="preconnect" href="https://fonts.googleapis.com">
  16. <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  17. <link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
  18. <div id="box">
  19. <button class="main" id="accordian">Abrir/Fechar</button>
  20. <div class="main" id="box2">
  21. <center><p class="inputans" >📖 Krakdemy 📖</p></center>
  22. <br>
  23. <left><section><label id="ansHead">Respostas:</label></section></left>
  24.  
  25. <center id="mainCen">
  26. <section><label id="ansBreak">&nbsp;</label></section>
  27.  
  28. </center>
  29. <section><label>&nbsp;</label></section>
  30. <button onclick="location.reload()" class="inputans">Limpar lista</button>
  31. </div>
  32. <div class="main" id="box2">
  33. <center><p class="inputans" >Ajuda</p></center>
  34. <br>
  35. <left><section><label id="ansHead">/frac significa que é uma fração</label></section></left>
  36. <left><section><label id="ansHead">/times geralmente é uma multiplicação</label></section></left>
  37. </div>
  38. </div>
  39.  
  40. <style>
  41. #box {
  42. z-index: 9999;
  43. position: fixed;
  44. top: 0;
  45. right: 0;}
  46. #box2 {
  47. padding: 15px;
  48. margin-bottom: 5px;
  49. display: grid;
  50. border-radius: 10px;};
  51. section {
  52. display: flex;
  53. justify-content: space-between;margin:5px;}
  54. .main {
  55. background-color: #1E1E1E;
  56. letter-spacing: 2px;
  57. border-radius: 5px;
  58. font-weight: none;
  59. font-size: 11px;
  60. font-family: 'Roboto', sans-serif;
  61. color:#FFFFFF;
  62. webkit-user-select: all;}
  63. .pwhite {
  64. border-bottom:2px solid white;
  65.  
  66. }
  67. #accordian {
  68. width: 100%;
  69. border: 0;
  70. cursor: pointer;
  71. border-radius: 25px;}
  72. .inputans {
  73. border: 0;
  74. cursor: pointer;
  75. border-radius: 5px;
  76. background-color: #F2F2F2;
  77. color: black;
  78. font-family: 'Roboto', sans-serif; color: #1e1e1e
  79. }
  80. .inputans:hover {
  81. background-color: #121212;
  82. color: white;
  83. }
  84. .toggleclass {
  85. text-align: center;
  86. }
  87. </style>
  88. `
  89.  
  90.  
  91.  
  92. function get(x) { return document.getElementById(x); }
  93.  
  94. let overlay = document.createElement("div");
  95. overlay.innerHTML = overlayHTML;
  96. document.body.appendChild(overlay);
  97.  
  98. let acc = get("accordian"),
  99. darkToggle = get("darkToggle"),
  100. ansbutton = get("inputans"),
  101. ansbutton2 = get("inputans2")
  102.  
  103. acc.onclick = function() {
  104. let panel = get("box2");
  105. let acc = get("accordian")
  106. if (panel.style.display == "grid") panel.style.display = "none";
  107. else { panel.style.display = "grid";}
  108.  
  109. }
  110.  
  111.  
  112. 'use strict';
  113. window.loaded = false;
  114.  
  115. class Answer {
  116.  
  117. constructor(answer, type) {
  118. this.body = answer;
  119. this.type = type;
  120. }
  121.  
  122. get isMultiChoice() {
  123. return this.type == "multiple_choice";
  124. }
  125.  
  126. get isFreeResponse() {
  127. return this.type == "free_response";
  128. }
  129.  
  130. get isExpression() {
  131. return this.type == "expression";
  132. }
  133.  
  134. get isDropdown() {
  135. return this.type == "dropdown";
  136. }
  137.  
  138. log() {
  139. const answer = this.body;
  140.  
  141. answer.map(ans => {
  142. if (typeof ans == "string") {
  143. if (ans.includes("web+graphie")) {
  144. this.body[this.body.indexOf(ans)] = "";
  145. this.printImage(ans);
  146. } else {
  147. answer[answer.indexOf(ans)] = ans.replaceAll(" ", "");
  148. }
  149. }
  150. });
  151.  
  152.  
  153. }
  154.  
  155.  
  156. }
  157.  
  158. const originalFetch = window.fetch;
  159. window.fetch = function () {
  160. return originalFetch.apply(this, arguments).then(async (res) => {
  161. if (res.url.includes("/getAssessmentItem")) {
  162. const clone = res.clone();
  163. const json = await clone.json()
  164. let item, question;
  165.  
  166.  
  167. item = json.data.assessmentItem.item.itemData;
  168. question = JSON.parse(item).question;
  169.  
  170.  
  171. Object.keys(question.widgets).map(widgetName => {
  172. switch (widgetName.split(" ")[0]) {
  173. case "numeric-input":
  174. return freeResponseAnswerFrom(question).log();
  175. case "radio":
  176. return multipleChoiceAnswerFrom(question).log();
  177. case "expression":
  178. return expressionAnswerFrom(question).log();
  179. case "dropdown":
  180. return dropdownAnswerFrom(question).log();
  181. }
  182. });
  183. }
  184.  
  185. if (!window.loaded) {
  186. console.clear();
  187.  
  188. window.loaded = true;
  189. }
  190.  
  191. return res;
  192. })
  193. }
  194.  
  195. let curAns = 1
  196.  
  197. function freeResponseAnswerFrom(question) {
  198. const answer = Object.values(question.widgets).map((widget) => {
  199. if (widget.options?.answers) {
  200. return widget.options.answers.map(answer => {
  201. if (answer.status == "correct") {
  202.  
  203. var parNumCurAns = "parNum" + curAns
  204. var createPar = document.createElement('section')
  205. createPar.innerHTML = answer.value
  206. document.getElementById('ansBreak').append(createPar)
  207.  
  208. curAns++
  209. }
  210. });
  211. }
  212. }).flat().filter((val) => { return val !== undefined; });
  213.  
  214. return new Answer(answer, "free_response");
  215. }
  216.  
  217.  
  218.  
  219. function multipleChoiceAnswerFrom(question) {
  220. const answer = Object.values(question.widgets).map((widget) => {
  221. if (widget.options?.choices) {
  222. return widget.options.choices.map(choice => {
  223. if (choice.correct) {
  224.  
  225. var parNumCurAns = "parNum" + curAns
  226. var createPar = document.createElement('section')
  227. createPar.innerHTML = choice.content
  228. document.getElementById('ansBreak').append(createPar)
  229.  
  230. curAns++
  231.  
  232. }
  233. });
  234. }
  235. }).flat().filter((val) => { return val !== undefined; });
  236.  
  237. return new Answer(answer, "multiple_choice");
  238. }
  239.  
  240. function expressionAnswerFrom(question) {
  241. const answer = Object.values(question.widgets).map((widget) => {
  242. if (widget.options?.answerForms) {
  243. return widget.options.answerForms.map(answer => {
  244. if (Object.values(answer).includes("correct")) {
  245.  
  246. var parNumCurAns = "parNum" + curAns
  247. var createPar = document.createElement('section')
  248. createPar.innerHTML = answer.value
  249. document.getElementById('ansBreak').append(createPar)
  250.  
  251. curAns++
  252.  
  253. }
  254. });
  255. }
  256. }).flat();
  257.  
  258. return new Answer(answer, "expression");
  259. }
  260.  
  261. function dropdownAnswerFrom(question) {
  262. const answer = Object.values(question.widgets).map((widget) => {
  263. if (widget.options?.choices) {
  264. return widget.options.choices.map(choice => {
  265. if (choice.correct) {
  266.  
  267. var parNumCurAns = "parNum" + curAns
  268. var createPar = document.createElement('section')
  269. createPar.innerHTML = choice.content
  270. document.getElementById('ansBreak').append(createPar)
  271.  
  272. curAns++
  273. }
  274. });
  275. }
  276. }).flat();
  277.  
  278. return new Answer(answer, "dropdown");
  279. }
  280. })();