Cheat para CMSP

Cheat do CMSP by marco10pc, modificado

目前为 2024-10-16 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Cheat para CMSP
  3. // @namespace https://cmspweb.ip.tv/
  4. // @version 1.1
  5. // @description Cheat do CMSP by marco10pc, modificado
  6. // @connect cmsp.ip.tv
  7. // @connect edusp-api.ip.tv
  8. // @author Rafael Gustavo Nogueira (marco10pc)
  9. // @match https://cmsp.ip.tv/*
  10. // @icon https://edusp-static.ip.tv/permanent/66aa8b3a1454f7f2b47e21a3/full.x-icon
  11. // @license GNU Affero General Public License v3.0
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. let lesson_regex = /https:\/\/cmsp\.ip\.tv\/mobile\/tms\/task\/\d+\/apply/;
  18. console.log("-- STARTING CMSP CHEETO By marcos10pc --");
  19.  
  20. function transformJson(jsonOriginal) {
  21. let novoJson = {
  22. status: "submitted",
  23. accessed_on: jsonOriginal.accessed_on,
  24. executed_on: jsonOriginal.executed_on,
  25. answers: {}
  26. };
  27.  
  28. for (let questionId in jsonOriginal.answers) {
  29. let question = jsonOriginal.answers[questionId];
  30. let taskQuestion = jsonOriginal.task.questions.find(q => q.id === parseInt(questionId));
  31.  
  32. if (taskQuestion.type === "order-sentences") {
  33. let answer = taskQuestion.options.sentences.map(sentence => sentence.value);
  34. novoJson.answers[questionId] = {
  35. question_id: question.question_id,
  36. question_type: taskQuestion.type,
  37. answer: answer
  38. };
  39. } else if (taskQuestion.type === "fill-words") {
  40. let pre_anwser = taskQuestion.options
  41. let anwser = pre_anwser.phrase.map(item => item.value);
  42. //console.log(`[DEBUG] ${JSON.stringify(anwser)}`)
  43. novoJson.answers[questionId] = {
  44. question_id: question.question_id,
  45. question_type: taskQuestion.type,
  46. answer: anwser
  47. };
  48.  
  49. } else if (taskQuestion.type === "text_ai") {
  50. let answer = taskQuestion.comment.replace(/<\/?p>/g, '');
  51. novoJson.answers[questionId] = {
  52. question_id: question.question_id,
  53. question_type: taskQuestion.type,
  54. answer: {
  55. "0": answer
  56. }
  57. };
  58. } else if (taskQuestion.type === "fill-letters") {
  59. let answer = taskQuestion.options.answer;
  60. novoJson.answers[questionId] = {
  61. question_id: question.question_id,
  62. question_type: taskQuestion.type,
  63. answer: answer
  64. };
  65. } else if (taskQuestion.type === "cloud") {
  66. let answer = taskQuestion.options.ids;
  67. novoJson.answers[questionId] = {
  68. question_id: question.question_id,
  69. question_type: taskQuestion.type,
  70. answer: answer
  71. };
  72. } else {
  73. let answer = Object.fromEntries(
  74. Object.keys(taskQuestion.options).map(optionId => [optionId, taskQuestion.options[optionId].answer])
  75. );
  76. novoJson.answers[questionId] = {
  77. question_id: question.question_id,
  78. question_type: taskQuestion.type,
  79. answer: answer
  80. };
  81. }
  82. }
  83. return novoJson;
  84. }
  85.  
  86. let oldHref = document.location.href;
  87. const observer = new MutationObserver(() => {
  88. if (oldHref !== document.location.href) {
  89. oldHref = document.location.href;
  90. if (lesson_regex.test(oldHref)) {
  91. console.log("[DEBUG] LESSON DETECTED");
  92.  
  93. let x_auth_key = JSON.parse(sessionStorage.getItem("cmsp.ip.tv:iptvdashboard:state")).auth.auth_token;
  94. let room_name = JSON.parse(sessionStorage.getItem("cmsp.ip.tv:iptvdashboard:state")).room.room.name;
  95. let id = oldHref.split("/")[6];
  96. console.log(`[DEBUG] LESSON_ID: ${id} ROOM_NAME: ${room_name}`);
  97.  
  98. let draft_body = {
  99. status: "draft",
  100. accessed_on: "room",
  101. executed_on: room_name,
  102. answers: {}
  103. };
  104.  
  105. const sendRequest = (method, url, data, callback) => {
  106. const xhr = new XMLHttpRequest();
  107. xhr.open(method, url);
  108. xhr.setRequestHeader("X-Api-Key", x_auth_key);
  109. xhr.setRequestHeader("Content-Type", "application/json");
  110. xhr.onload = () => callback(xhr);
  111. xhr.onerror = () => console.error('Request failed');
  112. xhr.send(data ? JSON.stringify(data) : null);
  113. };
  114.  
  115. sendRequest("POST", `https://edusp-api.ip.tv/tms/task/${id}/answer`, draft_body, (response) => {
  116. console.log("[DEBUG] DRAFT_DONE, RESPONSE: ", response.responseText);
  117. let response_json = JSON.parse(response.responseText);
  118. let task_id = response_json.id;
  119. let get_anwsers_url = `https://edusp-api.ip.tv/tms/task/${id}/answer/${task_id}?with_task=true&with_genre=true&with_questions=true&with_assessed_skills=true`;
  120.  
  121. console.log("[DEBUG] Getting Answers...");
  122.  
  123. sendRequest("GET", get_anwsers_url, null, (response) => {
  124. console.log(`[DEBUG] Get Answers request received response`);
  125. console.log(`[DEBUG] GET ANSWERS RESPONSE: ${response.responseText}`);
  126. let get_anwsers_response = JSON.parse(response.responseText);
  127. let send_anwsers_body = transformJson(get_anwsers_response);
  128.  
  129. console.log(`[DEBUG] Sending Answers... BODY: ${JSON.stringify(send_anwsers_body)}`);
  130.  
  131. sendRequest("PUT", `https://edusp-api.ip.tv/tms/task/${id}/answer/${task_id}`, send_anwsers_body, (response) => {
  132. if (response.status !== 200) {
  133. alert(`[ERROR] An error occurred while sending the answers. RESPONSE: ${response.responseText}`);
  134. }
  135. console.log(`[DEBUG] Answers Sent! RESPONSE: ${response.responseText}`);
  136.  
  137. const watermark = document.querySelector('.MuiTypography-root.MuiTypography-body1.css-1exusee');
  138. if (watermark) {
  139. watermark.textContent = 'Rafael G. Nogueira';
  140. watermark.style.fontSize = '70px';
  141. setTimeout(() => {
  142. document.querySelector('button.MuiButtonBase-root.MuiButton-root.MuiLoadingButton-root.MuiButton-contained.MuiButton-containedInherit.MuiButton-sizeMedium.MuiButton-containedSizeMedium.MuiButton-colorInherit.css-prsfpd').click();
  143. }, 500);
  144. }
  145. });
  146. });
  147. });
  148. }
  149. }
  150. });
  151.  
  152. observer.observe(document.body, {
  153. childList: true,
  154. subtree: true
  155. });
  156. })();