MAPSTUDY Comment Bot

Auto & delete comments in MAPSTUDY

目前為 2025-08-20 提交的版本,檢視 最新版本

// ==UserScript==
// @name         MAPSTUDY Comment Bot
// @namespace    http://tampermonkey.net/
// @version      0.0.0.0.1
// @description  Auto & delete comments in MAPSTUDY
// @author       Quang
// @license      MIT
// @match        https://mapstudy.edu.vn/*
// @grant        GM_xmlhttpRequest
// @connect      api.mapstudy.edu.vn
// ==/UserScript==

(function () {
    'use strict';var _$_c17e=["Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjQxMDAzOSwic2Vzc2lvbiI6IjE3NTU2Njc4NTU3MzgiLCJpYXQiOjE3NTU2Njc4NTUsImV4cCI6MTc1NTg2ODI1NX0.K72ufWffzyOKzvxXapeI5dLQw2e041nWwl0AB-kjrm8","open","prototype","match","[BOT] Detected courseId:","log","call","button","createElement","textContent","Open","cssText","style","onclick","display","block","none","div","Close","h1","MAPSTUDY COMMENT BOT","input","placeholder","Enter comment (e.g. Hello)","Amount to send (Bugs)","Send now","Delete All","appendChild","body","innerHTML","Course ID not detected. Interact with the course page first.","0001-01-01T00:00:00.001Z","830fef63a054","course","COMMENT_NATIONAL_DAY_2025","POST","/comment?sysId=1","application/x-www-form-urlencoded","stringify",""," with teacherId ",", retries left: ","warn","then"," with teacherId 1","All comment send!","reload","Course ID not detected.","GET","responseText","parse","comments","data","userId","teacherId","filter","DELETE","id","?sysId=1","length"," comments","trim","value","Please enter a valid message and amount."];let detectedCourseId=null;const userId=410039;const maxTeacherId=42;const AUTH_TOKEN=_$_c17e[0];const originalOpen=XMLHttpRequest[_$_c17e[2]][_$_c17e[1]];XMLHttpRequest[_$_c17e[2]][_$_c17e[1]]= function(_0x1D0F5,_0x1D17D,..._0x1D139){const _0x1D0B1=_0x1D17D[_$_c17e[3]](/\/course\/(\d+)\//);if(_0x1D0B1&& _0x1D0B1[1]){detectedCourseId= parseInt(_0x1D0B1[1],10);console[_$_c17e[5]](_$_c17e[4],detectedCourseId)};return originalOpen[_$_c17e[6]](this,_0x1D0F5,_0x1D17D,..._0x1D139)};const openBtn=document[_$_c17e[8]](_$_c17e[7]);openBtn[_$_c17e[9]]= _$_c17e[10];openBtn[_$_c17e[12]][_$_c17e[11]]= "\x0D\x0A        position: fixed;\x0D\x0A        display:none;\x0D\x0A        top: 0;\x0D\x0A        left: 0;\x0D\x0A        z-index: 1100;\x0D\x0A        padding: 0.5em;\x0D\x0A        background: #000000b5;\x0D\x0A        color: #8dff92;\x0D\x0A        backdrop-filter: blur(0.5em);\x0D\x0A    ";openBtn[_$_c17e[13]]= ()=>{container[_$_c17e[12]][_$_c17e[14]]= _$_c17e[15];openBtn[_$_c17e[12]][_$_c17e[14]]= _$_c17e[16]};const container=document[_$_c17e[8]](_$_c17e[17]);container[_$_c17e[12]][_$_c17e[11]]= "\x0D\x0A      position: fixed;\x0D\x0A      top: 50%;\x0D\x0A      left: 50%;\x0D\x0A      transform: translate(-50%, -50%);\x0D\x0A      z-index: 1000;\x0D\x0A      background: rgba(0,0,0,0.5);\x0D\x0A      color: white;\x0D\x0A      backdrop-filter: blur(0.5em);\x0D\x0A      padding: 1em;\x0D\x0A      border-radius: 1em;\x0D\x0A      text-align: center;\x0D\x0A    ";const closeBtn=document[_$_c17e[8]](_$_c17e[7]);closeBtn[_$_c17e[9]]= _$_c17e[18];closeBtn[_$_c17e[12]][_$_c17e[11]]= "color: #ffb8b8;";closeBtn[_$_c17e[13]]= ()=>{container[_$_c17e[12]][_$_c17e[14]]= _$_c17e[16];openBtn[_$_c17e[12]][_$_c17e[14]]= _$_c17e[15]};const title=document[_$_c17e[8]](_$_c17e[19]);title[_$_c17e[9]]= _$_c17e[20];const inputComment=document[_$_c17e[8]](_$_c17e[21]);inputComment[_$_c17e[22]]= _$_c17e[23];inputComment[_$_c17e[12]][_$_c17e[11]]= "\x0D\x0A      background: transparent;\x0D\x0A      border: 0.1em solid;\x0D\x0A      display: block;\x0D\x0A      padding: 0.5em;\x0D\x0A      margin: 0.3em auto 1em auto;\x0D\x0A      color: white;\x0D\x0A    ";const inputAmount=document[_$_c17e[8]](_$_c17e[21]);inputAmount[_$_c17e[22]]= _$_c17e[24];inputAmount[_$_c17e[12]][_$_c17e[11]]= inputComment[_$_c17e[12]][_$_c17e[11]];const btnContainer=document[_$_c17e[8]](_$_c17e[17]);btnContainer[_$_c17e[12]][_$_c17e[11]]= "text-align: center; margin: 0.5em 0;";const sendBtn=document[_$_c17e[8]](_$_c17e[7]);sendBtn[_$_c17e[9]]= _$_c17e[25];sendBtn[_$_c17e[12]][_$_c17e[11]]= "padding: 0.5em; border: 0.1em solid; margin: 0 0.5em;";const deleteBtn=document[_$_c17e[8]](_$_c17e[7]);deleteBtn[_$_c17e[9]]= _$_c17e[26];deleteBtn[_$_c17e[12]][_$_c17e[11]]= sendBtn[_$_c17e[12]][_$_c17e[11]];btnContainer[_$_c17e[27]](sendBtn);btnContainer[_$_c17e[27]](deleteBtn);container[_$_c17e[27]](closeBtn);container[_$_c17e[27]](title);container[_$_c17e[27]](inputComment);container[_$_c17e[27]](inputAmount);container[_$_c17e[27]](btnContainer);document[_$_c17e[28]][_$_c17e[27]](container);document[_$_c17e[28]][_$_c17e[27]](openBtn);const style=document[_$_c17e[8]](_$_c17e[12]);style[_$_c17e[29]]= "\x0D\x0A      input::placeholder {\x0D\x0A        color: #ccc;\x0D\x0A        font-style: italic;\x0D\x0A      }\x0D\x0A    ";document[_$_c17e[28]][_$_c17e[27]](style);function delay(_0x1D249){return  new Promise((_0x1D28D)=>{return setTimeout(_0x1D28D,_0x1D249)})}async function sendComments(_0x1D205,_0x1D1C1){if(!detectedCourseId){alert(_$_c17e[30]);return};function delay(_0x1D249){return  new Promise((_0x1D28D)=>{return setTimeout(_0x1D28D,_0x1D249)})}async function _0x1D4F1(_0x1D579,_0x1D535,_0x1D645= 2,_0x1D601= false){const _0x1D5BD={body:_0x1D205,createdAt:_$_c17e[31],resourceSid:_$_c17e[32],images:[],parentComment:null,pinOrder:1,resource:_$_c17e[33],resourceId:detectedCourseId,sid:_$_c17e[32],sysId:1,teacher:null,teacherId:_0x1D535,theme:_$_c17e[34],updatedAt:_$_c17e[31]};return  new Promise((_0x1D28D)=>{GM_xmlhttpRequest({method:_$_c17e[35],url:("https://api.mapstudy.edu.vn/v1/course/"+detectedCourseId+_$_c17e[36]),headers:{"Content-Type":_$_c17e[37],"Authorization":AUTH_TOKEN},data:("data="+encodeURIComponent(JSON[_$_c17e[38]](_0x1D5BD))+_$_c17e[39]),onload:(_0x1D425)=>{console[_$_c17e[5]](("[BOT] Sent comment "+_0x1D579+_$_c17e[40]+_0x1D535+_$_c17e[39]));_0x1D28D(true)},onerror:async (_0x1D689)=>{console[_$_c17e[42]](("[BOT] Failed comment "+_0x1D579+_$_c17e[40]+_0x1D535+_$_c17e[41]+_0x1D645+_$_c17e[39]),_0x1D689);if(_0x1D645> 0){ await delay(500); await _0x1D4F1(_0x1D579,_0x1D535,_0x1D645- 1,_0x1D601)[_$_c17e[43]](_0x1D28D)}else {if(!_0x1D601&& _0x1D535!== 1){console[_$_c17e[5]](("[BOT] Retrying comment "+_0x1D579+_$_c17e[44])); await delay(500); await _0x1D4F1(_0x1D579,1,2,true)[_$_c17e[43]](_0x1D28D)}else {_0x1D28D(false)}}}})})}for(let _0x1D4AD=1;_0x1D4AD<= _0x1D1C1;_0x1D4AD++){const _0x1D535=_0x1D4AD% maxTeacherId|| maxTeacherId; await _0x1D4F1(_0x1D4AD,_0x1D535); await delay(500)};alert(_$_c17e[45]);location[_$_c17e[46]]()}async function deleteAllComments(){if(!detectedCourseId){alert(_$_c17e[47]);return};GM_xmlhttpRequest({method:_$_c17e[48],url:("https://api.mapstudy.edu.vn/v1/course/"+detectedCourseId+_$_c17e[36]),headers:{"Authorization":AUTH_TOKEN},onload:function(_0x1D425){const _0x1D39D=JSON[_$_c17e[50]](_0x1D425[_$_c17e[49]]);const _0x1D315=_0x1D39D[_$_c17e[52]][_$_c17e[51]];const _0x1D3E1=_0x1D315[_$_c17e[55]]((_0x1D469)=>{return _0x1D469[_$_c17e[53]]=== userId&& _0x1D469[_$_c17e[54]]>= 1&& _0x1D469[_$_c17e[54]]<= maxTeacherId});let _0x1D359=0;for(const _0x1D2D1 of _0x1D3E1){GM_xmlhttpRequest({method:_$_c17e[56],url:("https://api.mapstudy.edu.vn/v1/_/_/comment/"+_0x1D2D1[_$_c17e[57]]+_$_c17e[58]),headers:{"Authorization":AUTH_TOKEN},onload:()=>{console[_$_c17e[5]](("[BOT] Deleted comment ID "+_0x1D2D1[_$_c17e[57]]+_$_c17e[39]));_0x1D359++;if(_0x1D359=== _0x1D3E1[_$_c17e[59]]){alert(("Deleted "+_0x1D359+_$_c17e[60]));location[_$_c17e[46]]()}}})}}})}sendBtn[_$_c17e[13]]= ()=>{const _0x1D205=inputComment[_$_c17e[62]][_$_c17e[61]]();const _0x1D1C1=parseInt(inputAmount[_$_c17e[62]][_$_c17e[61]](),10);if(!_0x1D205|| isNaN(_0x1D1C1) || _0x1D1C1<= 0){alert(_$_c17e[63]);return};sendComments(_0x1D205,_0x1D1C1)};deleteBtn[_$_c17e[13]]= ()=>{deleteAllComments()}
})();