巴蜀OJ自动发信机+自动删信机

自动向指定用户发送n条消息,1秒一条。自动删除当前页码上的所有信息,瞬间删完。自动删除所有信息,几秒删完。

目前為 2024-06-06 提交的版本,檢視 最新版本

// ==UserScript==
// @name            巴蜀OJ自动发信机+自动删信机
// @name:en         Auto mail sender + deleter for BSOJ
// @namespace       https://greasyfork.org/users/1265383
// @version         3.1
// @description     自动向指定用户发送n条消息,1秒一条。自动删除当前页码上的所有信息,瞬间删完。自动删除所有信息,几秒删完。
// @description:en  Automatically send n messages to the specified user, one message every second.Automatically deletes all information on the current page number in an instant..Automatically deletes all information quickly.
// @author          123asdf123(luogu 576074)
// @match           https://oj.bashu.com.cn/code/mail.*
// @icon            https://oj.bashu.com.cn/favicon.ico
// @license         GPL3.0+SATA
// @grant           none
// ==/UserScript==
var sendb=document.getElementById("sendnew"),autosendb=document.createElement("span"),delb=document.createElement("span"),clearb=document.createElement("span"),automail=document.createElement("div");
function insertAfter(newElement, targetElement) {
    let parent = targetElement.parentNode;
    if (parent.lastChild == targetElement) {
        parent.appendChild(newElement);
    } else {
        parent.insertBefore(newElement, targetElement.nextSibling);
    }
}
function send(user,title,content){
    sendb.click();
    document.getElementById("to_input").value=user;
    document.getElementById("title_input").value=title;
    document.getElementById("detail_input").value=content;
    let d=$('#send_form').serialize();
    while(document.body.children.length){
        document.body.children[0].remove();
    }
    window.document.body.appendChild(document.createElement("div"))
    while(localStorage["auto-send-remain"]!=0){
        localStorage["auto-send-remain"]--;
        $.ajax({
            type:"POST",
            url:"ajax_mailfunc.php?op=send",
            data:d,
        });
//        setTimeout("",1000);
    }
}
function sendmessage(){
    localStorage["auto-send-remain"]=parseInt(document.getElementById("auto_times_input").value);
    localStorage["auto-send-user"]=document.getElementById("auto_to_input").value;
    localStorage["auto-send-title"]=document.getElementById("auto_title_input").value;
    localStorage["auto-send-content"]=document.getElementById("auto_detail_input").value;
    location.reload();
}
function offmessage(){
    automail.className="modal hide";
    automail.setAttribute("aria-hidden","true");
    automail.setAttribute("style","display: none;");
    document.getElementById("AutoMailModal_block").remove();
}
function getmessage(){
    automail.className="modal hide in";
    automail.setAttribute("aria-hidden","false");
    automail.setAttribute("style","display: block;");
    var blocker=document.createElement("div");
    blocker.className="modal-backdrop in";
    blocker.setAttribute("id","AutoMailModal_block");
    document.body.parentNode.appendChild(blocker);
    document.getElementById("hide_auto_modal").onclick=offmessage;
    document.getElementById("hide_auto_modal_x").onclick=offmessage;
    document.getElementById("auto_send_btn").onclick=sendmessage;
}
function delmessage(){
    let need=document.querySelectorAll(".btn.btn-mini.btn-danger");
    need.forEach(function (message) {
        message.click();
    });
}
function clearmessage(){
    let x=confirm("Are you sure?");
    if(x==true){
        localStorage["auto-clear"]=1;
        location.reload();
    }
}
(function() {
    'use strict';
    sendb.innerText="Send";
    sendb.className="btn btn-primary shortcut-hint";
    autosendb.innerHTML="Auto-Send";
    autosendb.className="btn btn-info";
    autosendb.setAttribute("style","margin:5px");
    autosendb.onclick=getmessage;
    delb.innerHTML="Delete all messages on this page";
    delb.className="btn btn-warning";
    delb.setAttribute("style","margin:5px");
    delb.onclick=delmessage;
    clearb.innerHTML="Clear all";
    clearb.className="btn btn-danger";
    clearb.setAttribute("style","margin:5px");
    clearb.onclick=clearmessage;
    automail.innerHTML="<div class=\"modal-header\"><a class=\"close\" id=\"hide_auto_modal_x\">×</a><h4>New Auto Message</h4></div><div class=\"modal-body\"><form class=\"form-horizontal\" id=\"send_form\"><fieldset><div class=\"control-group\"><label class=\"control-label\" for=\"auto_to_input\">To</label><div class=\"controls\"><input type=\"text\" class=\"input-medium\" id=\"auto_to_input\" name=\"touser\"></div></div><div class=\"control-group\"><label class=\"control-label\" for=\"auto_title_input\">Subject</label><div class=\"controls\"><input type=\"text\" style=\"width: 445px;\" id=\"auto_title_input\" name=\"title\"></div></div><div class=\"control-group\"><label class=\"control-label\" for=\"auto_detail_input\">Content</label><div class=\"controls\"><textarea style=\"width: 445px;\" id=\"auto_detail_input\" rows=\"10\" name=\"detail\"></textarea></div></div><div class=\"control-group\"><label class=\"control-label\" for=\"auto_times_input\">Times</label><div class=\"controls\"><input type=\"text\" style=\"width: 445px;\" id=\"auto_times_input\" name=\"title\"></div></div></fieldset></form><div class=\"alert alert-error hide margin-0\" id=\"send_result\" style=\"display: none;\"></div></div><div class=\"modal-footer\"><a href=\"#\" class=\"btn btn-primary\" id=\"auto_send_btn\">Send</a><a href=\"#\" class=\"btn\" id=\"hide_auto_modal\">Close</a></div>";
    automail.className="modal hide";
    automail.setAttribute("id","AutoMailModal");
    automail.setAttribute("aria-hidden","true");
    automail.setAttribute("style","display: none;");
    sendb.parentNode.appendChild(autosendb);
    sendb.parentNode.appendChild(delb);
    sendb.parentNode.appendChild(clearb);
    insertAfter(autosendb,sendb);
    document.getElementById("MailModal").parentNode.appendChild(automail);
    if(localStorage["auto-send-done"]==1){
        localStorage["auto-send-done"]=0;
        var done=document.createElement("div");
        done.innerHTML="Done.";
        done.className="alert alert-success center alert-popup";
        document.body.appendChild(done);
    }
    if(localStorage.getItem("auto-clear")==null){
        localStorage["auto-clear"]=0;
    }
    if(localStorage["auto-clear"]==1){
        let need=document.querySelectorAll(".btn.btn-mini.btn-danger");
        need.forEach(function (message) {
            message.click();
        });
        if(need.length==0){
            localStorage["auto-clear"]=0;
        }
        location.reload();
    }
    if(localStorage.getItem("auto-send-remain")==null){
        localStorage["auto-send-remain"]=0;
    }
    if(localStorage["auto-send-remain"]!=0){
        send(localStorage["auto-send-user"],localStorage["auto-send-title"],localStorage["auto-send-content"]);
        localStorage["auto-send-done"]=1;
        location.reload();
    }
})();