o meu codigo: // ==UserScript== // @name CMSP // @namespace https://cmspweb.ip.tv/ //…
- User
o meu codigo: // ==UserScript== // @name CMSP // @namespace https://cmspweb.ip.tv/ // @version 0.1 // @description CMSP Automatico? // @connect cmsp.ip.tv // @connect edusp-api.ip.tv // @author Caua // @match https://cmsp.ip.tv/* // @icon https://edusp-static.ip.tv/permanent/66aa8b3a1454f7f2b47e21a3/full.x-icon // @license GNU Affero General Public License v3.0 // ==/UserScript==
(function () { 'use strict';
// Criação do contêiner de botões let botoesContainer = document.createElement('div'); console.log("passou dos botões"); botoesContainer.innerHTML = ` <div class="container"> <h2>Hack CMSP</h2> <label>Quanto tempo quer esperar para responder?</label> <input id="tempoEspera" type="number" placeholder="Segundos" class="input-field"> <label>Responder quantas questões?</label> <input id="quantidadeQuestoes" type="number" placeholder="Quantidade" class="input-field"> <label>Todas as questões?</label> <select id="todasQuestoes" class="input-field"> <option value="sim">Sim</option> <option value="nao">Não</option> </select> <button onclick="responder()" id="responderButton" class="custom-button">Responder</button> </div>`;
// Estilos do contêiner botoesContainer.style.position = 'fixed'; botoesContainer.style.right = '20px'; botoesContainer.style.bottom = '20px'; botoesContainer.style.zIndex = '9999'; // Garantir que o z-index é alto o suficiente botoesContainer.style.backgroundColor = '#f9f9f9'; botoesContainer.style.padding = '20px'; botoesContainer.style.borderRadius = '12px'; botoesContainer.style.boxShadow = '0 8px 16px rgba(0, 0, 0, 0.2)'; botoesContainer.style.width = '300px'; botoesContainer.style.fontFamily = '"Segoe UI", Tahoma, Geneva, Verdana, sans-serif'; // Estilos adicionais const title = botoesContainer.querySelector('h2'); title.style.fontSize = '18px'; title.style.marginBottom = '10px'; title.style.color = '#333'; const inputs = botoesContainer.querySelectorAll('.input-field'); inputs.forEach(input => { input.style.width = '100%'; input.style.padding = '8px'; input.style.margin = '5px 0 15px 0'; input.style.borderRadius = '6px'; input.style.border = '1px solid #ccc'; input.style.fontSize = '14px'; }); // Estilo do botão "Responder" const button = botoesContainer.querySelector('#responderButton'); button.style.backgroundColor = '#007bff'; button.style.color = '#fff'; button.style.padding = '12px 20px'; button.style.border = 'none'; button.style.borderRadius = '6px'; button.style.cursor = 'pointer'; button.style.fontSize = '16px'; button.style.width = '100%'; button.style.transition = 'background-color 0.3s ease'; // Adicionar efeito hover no botão button.onmouseover = function () { button.style.backgroundColor = '#0056b3'; }; button.onmouseout = function () { button.style.backgroundColor = '#007bff'; }; // Adicionar o contêiner ao corpo da página function adicionarBotoes() { document.body.appendChild(botoesContainer); } // Verificar se o documento já está carregado if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', adicionarBotoes); console.log("paginacarregada"); } else { adicionarBotoes(); console.log("aaaaaaaaa"); } let responderfoiapertado = document.querySelector("#responderButton"); if (responderfoiapertado) { responderfoiapertado.addEventListener("click", responder, false) } console.log("script cmsp"); let enviarLicoes = /https:\/\/cmsp\.ip\.tv\/mobile\/tms\/task\/\d+\/apply/; function responder() { console.log("responderFunction"); function respostasJson(json) { console.log("respostasJson"); let novoJson = { status: "submitted", accessed_on: json.accessed_on, executed_on: json.executed_on, answers: {} }; for (let questionId in json.answers) { let pergunta = json.answers[questionId]; let infoPergunta = json.task.questions.find(q => q.id === parseInt(questionId)); const respostasA = { question_id: pergunta.question_id, question_type: infoPergunta.type, answer: resposta } let resposta; if (infoPergunta.type === "order-sentences") { resposta = infoPergunta.options.sentences.map(sentence => sentence.value); novoJson.answers[questionId] = respostasA; } else if (infoPergunta.type === "fill-words") { resposta = infoPergunta.options.phrase.map(item => item.value); novoJson.answers[questionId] = respostasA; } else if (infoPergunta.type === "text_ai") { resposta = infoPergunta.comment.replace(/<\/?p>/g, ''); novoJson.answers[questionId] = { question_id: pergunta.question_id, question_type: infoPergunta.type, answer: { "0": resposta } }; continue; } else if (infoPergunta.type === "cloud") { resposta = infoPergunta.options.ids; novoJson.answers[questionId] = respostasA; } else { resposta = Object.fromEntries( Object.keys(infoPergunta.options).map(optionId => [optionId, infoPergunta.options[optionId].answer]) ); } }; return novoJson; } let antigoLink = document.location.href const observar = new MutationObserver(() => { if (antigoLink !== document.location.href) { antigoLink = document.location.href; if (enviarLicoes.test(antigoLink)) { let authxkey = JSON.parse(sessionStorage.getItem("cmsp.ip.tv:iptvdashboard:state")).auth.auth_token; let sala = JSON.parse(sessionStorage.getItem("cmsp.ip.tv:iptvdashboard:state")).room.room.name; let id = antigoLink.split("/")[6]; let aaaaajaencheuosaco = { status: "draft", accessed_on: "room", executed_on: sala, answers: {} } const sendRequest = (method, url, data, callback) => { const xhr = new XMLHttpRequest(); xhr.open(method, url); xhr.setRequestHeader("X-Api-Key", authxkey); xhr.setRequestHeader("Content-Type", "application/json"); xhr.onload = () => callback(xhr); xhr.onerror = () => console.error('Request failed'); xhr.send(data ? JSON.stringify(data) : null); }; sendRequest("POST", `https://edusp-api.ip.tv/tms/task/${id}/answer`, aaaaajaencheuosaco, (response) => { let respostaJson = JSON.parse(response.responseText); let tarefaId = respostaJson.id; let respostasURL = `https://edusp-api.ip.tv/tms/task/${id}/answer/${tarefaId}?with_task=true&with_genre=true&with_questions=true&with_assessed_skills=true` sendRequest("GET", respostasURL, null, (response) => { let respostasdaURL = JSON.parse(response.responseText); let enviarRespostas = respostasJson(respostasdaURL) sendRequest("PUT", `https://edusp-api.ip.t v/tms/task/${id}/answer/${tarefaId}`, enviarRespostas, (response => { if (response.status !== 200) { alert(`DEU ERRO NESSA MERDA, VAI SE FODER, TOMAR NO MEIO DO SEU BUTICO CARALHO, deu erro, erro é o: ${response.responseText}`); } console.log("nsei"); })); }); }); } } }); - Assistant
- User
porque o meu não funciona?
- Assistant
- User
eu testei os dois codigos e somente o meu não funciona, o meu só aparece isso no console apos apertar o botão "responderFunction"
- Assistant