Me Salva | c h e e t o

God is good, dinner on the table

此脚本不应直接安装,它是供其他脚本使用的外部库。如果你需要使用该库,请在脚本元属性加入:// @require https://update.cn-greasyfork.org/scripts/519757/1496546/Me%20Salva%20%7C%20c%20h%20e%20e%20t%20o.js

  1. // ==UserScript==
  2. // @name Me Salva | c h e e t o
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-10-12
  5. // @description God is good, dinner on the table
  6. // @author marcos10pc
  7. // @match https://www.mesalva.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain_url=mesalva.com
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. //TODO: fazer opcao pra marcar video como concluido
  13.  
  14. let notificationCount = 0;
  15.  
  16. function createAndShowNotification(message) {
  17. return new Promise((resolve) => {
  18. if (document.getElementById('notification-styles') === null) {
  19. const e = document.createElement("style");
  20. e.id = 'notification-styles';
  21. e.innerHTML = `
  22. .notification {
  23. position: fixed;
  24. right: -320px;
  25. background-color: #333;
  26. color: #fff;
  27. padding: 10px;
  28. border-radius: 10px;
  29. box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  30. z-index: 1000;
  31. width: 320px;
  32. height: 60px;
  33. transition: right 0.5s ease;
  34. }
  35. .notification-content {
  36. position: relative;
  37. height: 100%;
  38. }
  39. .notification-content p {
  40. margin: 0;
  41. padding-top: 0;
  42. }
  43. .progress-bar {
  44. position: absolute;
  45. bottom: 5px;
  46. left: 50%;
  47. transform: translateX(-50%);
  48. height: 5px;
  49. background-color: #555;
  50. border-radius: 5px;
  51. width: 90%;
  52. overflow: hidden;
  53. }
  54. .progress-bar div {
  55. height: 100%;
  56. background-color: #bbb;
  57. width: 100%;
  58. animation: progress 5s linear forwards;
  59. }
  60. @keyframes progress {
  61. from {
  62. width: 100%;
  63. }
  64. to {
  65. width: 0;
  66. }
  67. }
  68. `;
  69. document.head.appendChild(e);
  70. }
  71.  
  72. notificationCount++;
  73.  
  74. const t = document.createElement("div");
  75. t.id = `notification-${notificationCount}`;
  76. t.className = "notification";
  77. t.style.bottom = `${20 + (notificationCount - 1) * 70}px`;
  78. t.style.right = "20px";
  79. t.innerHTML = `
  80. <div class="notification-content">
  81. <p>${message}</p>
  82. <div class="progress-bar"><div></div></div>
  83. </div>
  84. `;
  85. document.body.appendChild(t);
  86.  
  87. setTimeout(() => {
  88. t.style.right = "20px";
  89. }, 10);
  90.  
  91. setTimeout(() => {
  92. t.style.right = "-300px";
  93. setTimeout(() => {
  94. t.style.display = "none";
  95. notificationCount--;
  96. resolve();
  97. }, 500);
  98. }, 5000);
  99. });
  100. }
  101.  
  102. createAndShowNotification("sussy baka amongus");
  103. createAndShowNotification("halala marcos10pc");
  104. createAndShowNotification("se vc pagou por isso vc foi scammado");
  105.  
  106. function abacate(originalUrl) {
  107. const url = new URL(originalUrl);
  108. const pathParts = url.pathname.split('/');
  109. const exerciseId = pathParts[pathParts.length - 1];
  110. const newPath = `/app/_next/data/bm2l3_QV91OobhF5hOUQF/exercicio/${exerciseId}.json`;
  111. const params = new URLSearchParams(url.search);
  112. params.append('content', 'exercicio');
  113. params.append('content', exerciseId);
  114. return `https://www.mesalva.com${newPath}?${params.toString()}`;
  115. }
  116.  
  117. (async function() {
  118. 'use strict';
  119.  
  120. let catapimbas = /^https:\/\/www\.mesalva\.com\/app\/exercicio\/[a-z0-9\-]+(\?contexto=[^&]+&lista=[^&]+&modulo=[^&]+)?$/;
  121. console.log("-- sussy baka amongus marcos10pc --");
  122. let oldHref = document.location.href;
  123.  
  124. const observer = new MutationObserver(async () => {
  125. if (oldHref !== document.location.href) {
  126. oldHref = document.location.href;
  127.  
  128. if (catapimbas.test(oldHref)) {
  129. await new Promise(resolve => setTimeout(resolve, 1000));
  130. let answer_url = abacate(oldHref);
  131. console.log(`${answer_url}`);
  132.  
  133. try {
  134. let pre_answer = await fetch(answer_url, {
  135. method: "GET",
  136. });
  137.  
  138. if (!pre_answer.ok) {
  139. alert('uh, deu alguma porra ao tentar pegar resposta');
  140. return;
  141. }
  142.  
  143. let porra_answer = await pre_answer.json();
  144. const caralhos = porra_answer.pageProps.content.children[0].list;
  145. const damn = caralhos.find(resposta => resposta.isCorrect === true);
  146.  
  147. if (damn) {
  148. console.log(`[DEBUG] -- ${JSON.stringify(damn)} --`);
  149. createAndShowNotification(`RESPOSTA: ${damn.letter}`);
  150. const buttons = document.querySelectorAll('.exercise-answer__button');
  151. let clicked = false;
  152.  
  153. buttons.forEach(button => {
  154. const letterElement = button.querySelector('.exercise-answer__letter');
  155. if (letterElement && letterElement.textContent.trim() === damn.letter) {
  156. button.click();
  157. clicked = true;
  158. }
  159. });
  160. if (clicked) {
  161. const submitButton = document.querySelector('.btn.btn--primary.btn--size-md.submit-button');
  162. if (submitButton) {
  163. submitButton.click();
  164.  
  165. await new Promise(resolve => setTimeout(resolve, 1000));
  166.  
  167. const nextButton = document.querySelector('.btn.btn--primary.btn--size-md');
  168. if (nextButton) {
  169. nextButton.click();
  170. }
  171. }
  172. }
  173. } else {
  174. createAndShowNotification("Resposta não encontrada.");
  175. }
  176. } catch (error) {
  177. console.error('Erro no fetch:', error);
  178. }
  179. }
  180. }
  181. });
  182.  
  183. observer.observe(document.body, {
  184. childList: true,
  185. subtree: true
  186. });
  187. })();