反恰客脚本

try to take over the world!

目前為 2019-08-31 提交的版本,檢視 最新版本

// ==UserScript==
// @name         反恰客脚本
// @namespace    http://tampermonkey.net/
// @version      0.51
// @description  try to take over the world!
// @author       You
// @match        https://quan.ithome.com/*
// @grant        none
// ==/UserScript==

(function () {
  'use strict';

  if ($(".postcontent").length>0&&$(".postcontent").html().indexOf("class=\"appmore\"") > 0) {
    $(".postcontent").html("<p>稍等一下,正在异步获取帖子数据。。。</p>");
    var _id = location.href.substring(location.href.indexOf("/0/") + 3, location.href.indexOf("/0/") + 6) + location.href.substring(location.href.indexOf("/0/") + 7, location.href.indexOf("/0/") + 10);
    $.ajax({
      url: "https://ithome.fxxkcar.com/getithomepost.php?id=" + _id,
      dataType: 'jsonp',
      jsonp: "CallBack",
      success: function (data) {
        var _content = data.content;

        _content = replaceimg(_content, data.imgs);
        $(".postcontent").html(_content);
        var _repost = "<div id=\"ReplyList\"class=\"comment\"><div class=\"comm_title\"><div class=\"l\">恰克</div><div class=\"r\"><a class=\"order\">倒序显示</a></div></div><ul class=\"comm_list\"id=\"ulcommentlist\"></ul><ul class=\"comm_list\"id=\"ulcommentlistorder\"style=\"display:none\"></ul><ul class=\"comm_list\"id=\"LoadArticleReply\"></ul><script>var replypage=1;$(function(){pagereply(replypage,20,$(\'.order\').text())});</script><input type=\"hidden\"id=\"postid\"value=\"" + _id + "\"/></div><div class=\"more_comm\"><a id=\"pagecomment\" href=\"javascript:pagereply(++replypage,95,$(\'.order\').text());\">查看更多回复 ...</a></div>";
        $("#content").after($(_repost));



        var login = '';

        login += '                  <div class="answer" id="divanswer">';
        login += '     <div class="user_info"></div>';
        login += '     <div class="edit_form">';
        login += '         <input type="hidden" id="parentPostID" value="0" />';
        login += '         <script type="text/plain" id="myEditor" style="width:735px;height:220px;"></script>';
        login += '         <span id="replyMessage" style="color:red"></span>';
        login += '         <a href="javascript:;" class="answer_inpt" id="btnReply">回复</a>';
        login += '     </div>';
        login += ' </div>';
        login += ' <script src="//img.ithome.com/file/js/jquery/popwin.js"><\/script>';
        login += ' <script type="text/javascript" src="/statics/ueditor/ueditor.config.js?r=3"><\/script>';
        login += ' <script type="text/javascript" src="/statics/ueditor/ueditor.all.js?r=3"><\/script>';
        login += ' <script type="text/javascript" src="/statics/ueditor/lang/zh-cn/zh-cn.js?r=3"><\/script>';
        login += ' <link href="https://quan.ithome.com/statics/ueditor/themes/default/css/ueditor.css" type="text/css" rel="stylesheet">';
        login += ' <script src="https://quan.ithome.com/statics/ueditor/third-party/codemirror/codemirror.js" type="text/javascript" defer="defer"></script>';
        login += ' <link rel="stylesheet" type="text/css" href="https://quan.ithome.com/statics/ueditor/third-party/codemirror/codemirror.css">';

        $("#ReplyList").append($(login));

        window.editor = UE.getEditor('myEditor');

        editor.placeholder("<span style=color:#bbb>政治、色情、喷骂、引战、机型喷、水军、广告等违法违规行为将被封号。</span>");
        haodadaimages();
        $(".comm_title").delegate(".order",
          "click",
          function (e) {
            e.preventDefault();
            if ($(".order").html() == "倒序显示") {
              $("#ulcommentlist").hide();
              $("#ulcommentlistorder").fadeIn("slow");
              $(".order").html("正序显示");
              if ($("#ulcommentlistorder").html() == "") {
                var new_item = $("<div/>").load("/quan/GetAjaxData.aspx",
                  { "postid": $("#postid").val(), "type": "replypage", "page": 1, "order": "order" },
                  function () {
                  }).hide();
                $("#ulcommentlistorder").append(new_item);
                new_item.fadeIn("slow");
              }
            } else {
              $("#ulcommentlist").fadeIn("slow");
              $("#ulcommentlistorder").hide();
              $(".order").html("倒序显示");
            }


          })

        $(".comm_list").delegate(".reply_btn",
          "click",
          function () {
            oremarkbtn = $(this);
            modelreplyComment();
            addReply();
            $(".bbsmodal textarea").keydown(function (e) {
              if ((e.which === 13 || e.which === 10) && e.ctrlKey) {
                $(".answer_inpt").click()
              }
            })
          });
        $("#btnReply").click(function () { reply() });
        $("#btnModifyReply").click(function () { modifyReply() })
       
      }
    })

  }

  $(function () {
    
    haodadaimages();


  });

  function haodadaimages(){
    //添加按钮
    var _filebtn = '<label class="ui_button ui_button_primary" id="haodada_lab" for="haodada_file" style="display: block;cursor:pointer;margin-top: 10px;width: 90px;height: 40px;-webkit-border-radius: 2px;-moz-border-radius: 2px;border-radius: 2px;background: #d94141;color: #fff;text-align: center;text-decoration: none;line-height: 40px;">上传高清大图</label><input style="display:none;" type="file" id="haodada_file" name="profile_pic" multiple="multiple" accept=".jpg, .jpeg, .png, .gif">';
    $("#divanswer>.user_info").after(_filebtn);
    $(".pb_title").after(_filebtn);

    $("#haodada_file").change(function () {
      var formData = new FormData();
      var files = $("#haodada_file")[0].files;
      for (var _i = 0; _i < files.length; _i++) {
        $("#haodada_lab").text("正在上传");
        formData.append("fileupload", files[_i]);
        var _tempimg;
        $.ajax({
          url: "https://img.yyhy.me/upload.php?type=Sougou",
          type: "post",
          data: formData,
          cache: false,
          processData: false,
          contentType: false,
          async: true,
          dataType: "json",
          success: function (data) {
            console.log(data);
            editor.focus();
            editor.execCommand("inserthtml","<p><img src='"+data.msg+"?https://qimg.ithome.com/' _src='"+data.msg+"?https://qimg.ithome.com/'/></p>");
            $("#haodada_lab").text("上传高清大图");
          },
          error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert('图片上传失败 - ' + XMLHttpRequest.status);
            $("#haodada_lab").text("上传高清大图");
            console.error(XMLHttpRequest + textStatus + errorThrown);
          }
        })
      }

    });
  }

  function replaceimg(content, imgsArr) {
    var _rexArray = content.match(/(<!--IMG_)(\d|\d\d)-->/g);
    if (_rexArray == null) { return content; }
    for (var _i = 0; _i < _rexArray.length; _i++) {
      content = content.replace(_rexArray[_i], "<img src='" + imgsArr[_i] + "'/><br/>");
    }
    return content;
  }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址