9dm随机回帖

9大妈一键随机回复帖子, 切勿滥用, 违反9大妈论坛的规矩导致的后果, 作者一概不负.功能: 1. 添加随机回复按钮2. 添加快捷回复下拉框3. 添加评论管理器

スクリプトをインストール?
作者が勧める他のスクリプト

9dm自动填写计算も気に入るかもしれません。

スクリプトをインストール
このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
// ==UserScript==
// @name        9dm随机回帖
// @namespace   https://greasyfork.org/zh-CN/scripts/429335
// @icon        data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANEAAABECAYAAAAfkdAfAAAACXBIWXMAAAsSAAALEgHS3X78AAAKTWlDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVN3WJP3Fj7f92UPVkLY8LGXbIEAIiOsCMgQWaIQkgBhhBASQMWFiApWFBURnEhVxILVCkidiOKgKLhnQYqIWotVXDjuH9yntX167+3t+9f7vOec5/zOec8PgBESJpHmomoAOVKFPDrYH49PSMTJvYACFUjgBCAQ5svCZwXFAADwA3l4fnSwP/wBr28AAgBw1S4kEsfh/4O6UCZXACCRAOAiEucLAZBSAMguVMgUAMgYALBTs2QKAJQAAGx5fEIiAKoNAOz0ST4FANipk9wXANiiHKkIAI0BAJkoRyQCQLsAYFWBUiwCwMIAoKxAIi4EwK4BgFm2MkcCgL0FAHaOWJAPQGAAgJlCLMwAIDgCAEMeE80DIEwDoDDSv+CpX3CFuEgBAMDLlc2XS9IzFLiV0Bp38vDg4iHiwmyxQmEXKRBmCeQinJebIxNI5wNMzgwAABr50cH+OD+Q5+bk4eZm52zv9MWi/mvwbyI+IfHf/ryMAgQAEE7P79pf5eXWA3DHAbB1v2upWwDaVgBo3/ldM9sJoFoK0Hr5i3k4/EAenqFQyDwdHAoLC+0lYqG9MOOLPv8z4W/gi372/EAe/tt68ABxmkCZrcCjg/1xYW52rlKO58sEQjFu9+cj/seFf/2OKdHiNLFcLBWK8ViJuFAiTcd5uVKRRCHJleIS6X8y8R+W/QmTdw0ArIZPwE62B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6LchDw8YxpFjrDiXCfiTzN8eYh7WyF5AtzwWIR1PIKk8MrEUF2SErEnboV/KeYbEh83JBqRhzr2w2xbjAoky4ybSLIJSQMWB0owC77bhe68VkR4kOMApSHvvTQPdSwz0C9qkP1Mu3mcfyDG+g40JP2cIutbjwLvWhI1jR6qlOYDHw9w7Sg1Rpzqcf45zIPu/BpDTDC3iPpVLdFtQ1nUhoVueaxnrk2aWiOOnqNpOrPMWsSqFhcqMVtgfb+IdIc1JDPtdCJJ1CeP9TwJSfe6AvGOPox4KdQg4Q89yJ2idzNHpx6OAxdgluLqhSLpT3Xkx+JXNCTqmee6DsDc+XEDsh3i/pjraLoVyqwi6EuLkI2A6y2J/KGC9GRvWYDkq4ubQNWGJN9O+n3LnkCSYh6XMCVRGd5h3EnBHsTXLV+jvGletTTPQkuQ9ba1HMcwJdEBxN0/iaHCHwJ/R/Ir7Mzjc2sRR9xBalzo7/O+fO/LWuLx/yB4FQmdX5igdi+J4B6jMkxJ1IBsz3FfQj7gLlVqM9uoFCKgrR5JtPiUHl1URzoX73RZdZhvCmC6laNzWaLG5z07Va9cSWO65qjQ2vA+Z+LNUswS/7fL8bcfVJUM7B4qVqqXdpI22onykQmmVJ+1m8YNq1bnQecJK+oNRqx3zo77GOZZhVrSuDN2QwDi1dG4e98wJGS+wWVEPqSz+ha9Jy6fvjOQsBG/BonMbPGiQ9Ko1G9RGeJboNJD94B1ORCWRBbB0VsbvDeyYdoW+0nSjf8NACb5bZ8r3rN1AAAAAElFTkSuQmCC
// @match       *://www.9dmdamaomod.net/thread-*
// @match       *://www.9dmdamaomod.net/forum.php*
// @grant       GM_info
// @grant       GM_registerMenuCommand
// @grant       GM_unregisterMenuCommand
// @grant       GM_openInTab
// @grant       GM_getValue
// @grant       GM_setValue
// @grant       GM_notification
// @version     1.22
// @author      六记
// @description 9大妈一键随机回复帖子, 切勿滥用, 违反9大妈论坛的规矩导致的后果, 作者一概不负.功能: 1. 添加随机回复按钮2. 添加快捷回复下拉框3. 添加评论管理器
// ==/UserScript==

(function () {
  var defualtMsg = [
    "楼主@{author} 流弊~",
    "楼主, 为你点[b]赞[/b]",
    "感谢楼主分享",
    "66666666666666",
    "针不戳呀,写的针不戳!",
    "{hitokoto}",
  ]
  if(!GM_getValue('msg')){
    GM_setValue('msg',defualtMsg);
  }
  var MSG = GM_getValue('msg');
  var notification = {text: "", title:`${GM_info.script.name}`, image:`${GM_info.script.icon}`, timeout: 3000};
  var enable = GM_getValue('enable'), debug = GM_getValue('debug'), menu_enable_toggle_ID, menu_debug_toggle_ID, menu_feedBack_ID, menu_Quick_ID;
  registerMenuCommand();
  debugging("-->添加<随机回复>按钮<--");
  let scrolltop = document.querySelector(".c1scrolltop");
  let ulButton = document.querySelector(".c1scrolltop>ul");
  if(ulButton){
    try{
      let ul = ulButton.innerHTML;
      let html = '<li class="reply ac_show" id="action"><span>随机回复</span></li>';
      scrolltop.innerHTML = '<ul>'+ html + ul+'</ul>';
      let button = document.querySelector("#action");
      debugging(`-->找到<随机回复>按钮: ${button}<--`);
      debugging(`给按钮添加点击监听事件:\n-->${actionRandom}<--`);
      button.addEventListener("click", actionRandom);
      createSelect();
      console.log(`脚本: ${GM_info.script.name}启动成功`);
    }catch(exception){
      debugging(`-->触发异常: ${exception}<--`);
      console.log(`脚本: ${GM_info.script.name}启动失败`);
    }
  }

  function createSelect(){
    debugging("-->添加<简洁回复框>[下拉框]<--");
    let inputButton = document.querySelector("#fastposteditor");
    let selectButton = document.querySelector("#select");
    let option;
    MSG = GM_getValue('msg');
    if(!selectButton){
      option = '<option value="0">↓↓↓选择快捷回复↓↓↓</option>';
      for(let i in MSG){
        option += `<option value="${i+1}">${MSG[i]}</option>`;
      }
      let select = `<lable>快捷回复列表<select id="select">${option}</select></lable>`;
      inputButton.innerHTML = select + inputButton.innerHTML;
      selectButton = document.querySelector("#select");
      selectButton.addEventListener("change", actionQuick);
    }else{
      option = '<option value="0">↓↓↓选择快捷回复↓↓↓</option>';
      for(let i in MSG){
        option += `<option value="${i+1}">${MSG[i]}</option>`;
      }
      selectButton.innerHTML = option;
      selectButton.addEventListener("change", actionQuick);
    }
  }

  debugging("-->创建事件<--");
  // 随机回复事件
  function actionRandom(){
    debugging("-->触发点击<随机回复>事件<--");
    getAuthor();
    getHitokoto();
    let info = {
      author:window.author ? window.author : "楼主获取失败",
      hitokoto:window.hitokoto ? window.hitokoto : "一言获取失败",
    }
    debugging(`-->楼主: ${info.author}<--`);
    debugging(`-->一言: ${info.hitokoto}<--`);
    let inputButton;
    let initialValue;
    let initialStyleColor;
    let pushButton;
    MSG = GM_getValue('msg');
    let msgIndex = Math.floor(Math.random() * MSG.length);
    let msg = MSG[msgIndex].format(info);
    inputButton = document.querySelector("#vmessage");
    debugging(`-->获取快捷回复输入框: ${inputButton?"成功":"失败"}<--`);
    if(inputButton){
      initialValue = inputButton.value;
      initialStyleColor = inputButton.style.color;
      debugging("-->1. 获得焦点<--");
      inputButton.focus();
      inputButton.style.color = "rgb(0,0,0)";
      debugging(`-->2. 填写回复:${msg} ${msgIndex}<--`);
      inputButton.value = msg;
      debugging(`-->3. 点击<快捷回复>按钮<--`);
      pushButton = document.querySelector("#vreplysubmit");
    }else{
      try{
        inputButton = document.querySelector("#fastpostmessage");
        debugging(`-->获取简洁回复输入框: ${inputButton?"成功":"失败"}<--`);
        initialValue = inputButton.value;
        initialStyleColor = inputButton.style.color;
        debugging("-->1. 获得焦点<--");
        inputButton.focus();
        inputButton.style.color = "rgb(0,0,0)";
        debugging(`-->2. 填写回复:${msg} ${msgIndex}<--`);
        inputButton.value = msg;
        debugging(`-->3. 点击<发表回复>按钮<--`);
        pushButton = document.querySelector("#fastpostsubmit");    
      }catch(err){
        debugging(`-->触发未知BUG: 不存在<简洁回复>,也不存在<快捷回复>\n错误原因: ${err}<--`);
        return;
      }
    }
    enable = GM_getValue('enable');
    if(enable){
        debugging(`-->回帖内容:${inputButton.value} 默认内容:${initialValue} ${inputButton.value == initialValue?'相等, 不应该发送':'不相等, 应该发送'}<--`);
        if(inputButton.value != initialValue){
          pushButton.click();
          debugging(`-->4. 还原 还原样式:${initialStyleColor}<--`);
          let title = document.querySelector("#thread_subject");
          title = title?title.innerText:"帖子名称获取失败";
          notification.text = `帖子:${title}\n回帖成功, 回复内容:${inputButton.value}`
          GM_notification(notification); // 提示消息
          inputButton.blur();
          inputButton.style.color = initialStyleColor;
        }else{
          notification.text = `回帖失败, 回复内容:${inputButton.value}`
          GM_notification(notification); // 提示消息
        }
    }
  }
  // 快捷回复事件
  function actionQuick(){
    debugging("-->触发点击<快捷回复>事件<--");
    debugging("判断是否为网址第一页");
    getAuthor();
    getHitokoto();
    let info = {
      author:window.author ? window.author : "楼主获取失败",
      hitokoto:window.hitokoto ? window.hitokoto : "一言获取失败",
    }
    debugging(`-->楼主: ${info.author}<--`);
    debugging(`-->一言: ${info.hitokoto}<--`);
    let inputButton;
    let initialValue;
    let initialStyle;
    let pushButton;
    let selectButton = document.querySelector("#select");
    let Index = selectButton.selectedIndex - 1;
    if(Index > -1 && Index < MSG.length){
      let msg = MSG[Index].format(info);
      debugging("-->获取简洁回复输入框<--");
      inputButton = document.querySelector("#fastpostmessage");
      initialValue = inputButton.value;
      initialStyle = inputButton.style;
      debugging("-->1. 获得焦点<--");
      inputButton.focus();
      inputButton.style.color = "rgb(0,0,0)";
      debugging(`-->2. 填写回复:${msg} ${Index}<--`);
      inputButton.value = msg;
      debugging(`-->3. 点击<发表回复>按钮<--`);
      pushButton = document.querySelector("#fastpostsubmit");
      enable = GM_getValue('enable');
      if(enable){
        debugging(`-->回帖内容:${inputButton.value} 默认内容:${initialValue} ${inputButton.value == initialValue?'相等, 不应该发送':'不相等, 应该发送'}<--`);
        if(inputButton.value != initialValue){
          pushButton.click();
          debugging(`-->4. 还原 还原样式:${initialStyleColor}<--`);
          let title = document.querySelector("#thread_subject");
          title = title?title.innerText:"帖子名称获取失败";
          notification.text = `帖子:${title}\n回帖成功, 回复内容:${inputButton.value}`
          GM_notification(notification); // 提示消息
          inputButton.blur();
          inputButton.style.color = initialStyleColor;
        }else{
          notification.text = `回帖失败, 回复内容:${inputButton.value}`
          GM_notification(notification); // 提示消息
        }
      }
    }
  }
  // 打印调试信息
  function debugging(str){
    debug = GM_getValue('debug');
    if(debug){
      console.log(str)
    }
  }
  // box事件
  function boxClose(event){
    debugging("-->触发窗口关闭事件<--");
    event.stopPropagation();
    let box = document.querySelector("#box");
    if(box){
      box.hidden = true;
    }
  }
  function boxReset(event){
    debugging("-->触发评论重置事件<--");
    event.stopPropagation();
    let box = document.querySelector("#box");
    if(box){
      let text = document.querySelector("#text");
      text.value = defualtMsg.join("\n");
    }
  }
  function boxSave(event){
    debugging("-->触发评论保存事件<--");
    event.stopPropagation();
    let box = document.querySelector("#box");
    if(box){
      let text = document.querySelector("#text");
      let comment = text.value;
      let comments = comment.split("\n");
      debugging(comments);
      GM_setValue('msg', comments);
      createSelect()
    }
  }


  // -------- 获取信息事件-----------
  // 获取楼主名称
  function getAuthor(){
    let author = document.querySelector("#tath>a");
    if(author){
      window.author = author.title;
    }else{
      window.author = document.querySelector(".authi>.xw1").innerText;
    }
    return window.author
  }
  // 获取一言
  function getHitokoto(){
    let msg;
    let author;
    let httpRequest;
    try{
      if (window.XMLHttpRequest){// code for IE7, Firefox, Mozilla, etc.
      httpRequest=new XMLHttpRequest();
      }else if (window.ActiveXObject){// code for IE5, IE6
        httpRequest=new ActiveXObject("Microsoft.XMLHTTP");
      }
      httpRequest.open('GET', 'https://v1.hitokoto.cn/', true);
      httpRequest.send();
      httpRequest.onload = function () {
        if (httpRequest.readyState == 4 && httpRequest.status == 200) {
          let json = httpRequest.responseText;
          let jsonObject = eval('(' + json + ')');
          msg = jsonObject.hitokoto;
          author = jsonObject.from;
          let spaceLength = Math.floor(msg.length * 2);
          let space = new Array(spaceLength).join(" ");
          window.hitokoto = `${msg}\n${space}-${author}`;
        }else{
          alert(`HTTP请求失败,错误原因: 请求的URL的相应状态=${httpRequest.status}\n请求的结果状态=${httpRequest.readyState}`);
        }
      };
      httpRequest.onerror = function(){
         alert(`HTTP请求失败,错误原因: 请求的URL的相应状态=${httpRequest.status}\n请求的结果状态=${httpRequest.readyState}`);
      }
    }catch(err){
      debugging(`-->HTTP请求失败, 未知错误<--`);
    }
    
  }

  // 添加字符串format方法
  String.prototype.format = function(args) {
    var result = this;
    if (arguments.length > 0) {
        if (arguments.length == 1 && typeof (args) == "object") {
            for (var key in args) {
                if(args[key]!=undefined){
                    var reg = new RegExp("({" + key + "})", "g");
                    result = result.replace(reg, args[key]);
                }
            }
        }
        else {
            for (var i = 0; i < arguments.length; i++) {
                if (arguments[i] != undefined) {
                    //var reg = new RegExp("({[" + i + "]})", "g");//这个在索引大于9时会有问题
                    var reg = new RegExp("({)" + i + "(})", "g");
                    result = result.replace(reg, arguments[i]);
             }
          }
       }
    }
    return result;
  }

  // -------- 脚本菜单-----------
  debugging("-->创建脚本菜单<--");
  // 注册脚本菜单
  function registerMenuCommand() {
    if (menu_feedBack_ID || menu_enable_toggle_ID || menu_debug_toggle_ID || menu_Quick_ID){ // 如果反馈菜单ID不是 null,则删除所有脚本菜单
      GM_unregisterMenuCommand(menu_enable_toggle_ID);
      GM_unregisterMenuCommand(menu_debug_toggle_ID);
      GM_unregisterMenuCommand(menu_Quick_ID);
      GM_unregisterMenuCommand(menu_feedBack_ID);
      enable = GM_getValue('enable');
      debug = GM_getValue('debug');
    }
    menu_feedBack_ID = GM_registerMenuCommand('💬 反馈 & 建议 [Github]', function () {window.GM_openInTab('https://github.com/ACG-Q/script/issues/1', {active: true,insert: true,setParent: true});});
    menu_Quick_ID = GM_registerMenuCommand(`🧰 快捷评论管理`, menu_Quick);
    menu_enable_toggle_ID = GM_registerMenuCommand(`🔄 ${enable?'开启':'关闭'} 自动回复 - 点击切换`,  menu_enable_toggle);
    menu_debug_toggle_ID = GM_registerMenuCommand(`🔄 ${debug?'开启':'关闭'} 调试 - 点击切换`,  menu_debug_toggle);
  }
  // 切换事件
  function menu_enable_toggle() {
    enable = GM_getValue('enable');
    GM_setValue('enable', !enable);
    enable = GM_getValue('enable');
    notification.text = `已${enable?'开启':'关闭'} 自动回复`
    GM_notification(notification); // 提示消息
    registerMenuCommand(); // 重新注册脚本菜单
  };
  function menu_debug_toggle(){
    debug = GM_getValue('debug');
    GM_setValue('debug', !debug);
    debug = GM_getValue('debug');
    notification.text = `已${debug?'开启':'关闭'} 调试`
    GM_notification(notification); // 提示消息
    registerMenuCommand(); // 重新注册脚本菜单
  };
  function menu_Quick(){
    let box = document.querySelector("#box");
    let msg;
    if(!box){
      let quickHTML = '<div id="box" style="position: fixed; top: 105px; left: 1022px; padding: 10px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border-radius: 10px; z-index: 9; cursor: default; border: 1px solid;"><input type="button" value="X" id="close" style="border: 1px solid;background: rgba(255, 255, 255,0) none repeat scroll 0% 0%;padding: 0;float: right;width: 20px;border-radius: 5px;text-align: center;"><h1>快捷评论管理</h1><textarea id="text" autofocus="true" style="width: 250px;height: 200px;border-radius: 5px;border: 1px solid;"></textarea><br><input type="button" value="重置" id="reset" style="border: none;background: rgba(255, 255, 255,0) none repeat scroll 0% 0%;padding: 0;margin: 0;">&nbsp;&nbsp;<input type="button" value="保存" id="save" style="border: none;background: rgba(255, 255, 255,0) none repeat scroll 0% 0%;padding: 0;margin: 0;"></div>';
      let body = document.querySelector("body");
      body.innerHTML = quickHTML + body.innerHTML;
      box = document.querySelector("#box");
      let left = GM_getValue("boxLeft");
      let top = GM_getValue("boxTop");
      if(left || top){
        box.style.left = left + 'px';
        box.style.top = top + 'px';
      }
      let text = document.querySelector("#text");
      msg = GM_getValue('msg');
      text.value = msg.join("\n");

      // -----拖拽事件-------
      let x,y,isDown = false;
      //鼠标按下事件
      box.addEventListener('mousedown',mousedownbox);
      function mousedownbox(e) {
        //获取x坐标和y坐标
        x = e.clientX;
        y = e.clientY;

        //获取左部和顶部的偏移量
        left = box.offsetLeft;
        top = box.offsetTop;
        //开关打开
        isDown = true;
        //设置样式
        box.style.cursor = 'move';
      }
      //鼠标移动
      box.addEventListener('mousemove',mousemovebox);
      function mousemovebox(e) {
        if (isDown == false) {
            return;
        }
        //获取x和y
        let nx = e.clientX;
        let ny = e.clientY;
        //计算移动后的左偏移量和顶部的偏移量
        let nl = nx - (x - left);
        let nt = ny - (y - top);

        box.style.left = nl + 'px';
        box.style.top = nt + 'px';

        GM_setValue("boxLeft",nl);
        GM_setValue("boxTop",nt);
      }
      //鼠标抬起事件
      box.addEventListener('mouseup',mouseupbox);
      function mouseupbox() {
        //开关关闭
        isDown = false;
        box.style.cursor = 'default';
      }
      function noMove(event){
        debugging("-->触发不鼠标移动事件<--");
        isDown = false;
      }

      // -----按钮关闭事件-----
      let closeButton = document.querySelector("#close");
      let resetButton = document.querySelector("#reset");
      let saveButton = document.querySelector("#save");
      let button = document.querySelector("#action");

      closeButton.addEventListener("click", boxClose);
      resetButton.addEventListener("click", boxReset);
      saveButton.addEventListener("click", boxSave);

      closeButton.addEventListener("mousemove", noMove);
      resetButton.addEventListener("mousemove", noMove);
      saveButton.addEventListener("mousemove", noMove);
      text.addEventListener("mousemove", noMove);

      button.addEventListener("click", actionRandom);

    }else{
      box.hidden = !box.hidden;
      let text = document.querySelector("#text");
      msg = GM_getValue('msg');
      text.value = msg.join("\n");
    }
  }
})()