CSDN_Auto_Comment

CSDN一键点赞评论(学习)

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @license MIT
// @name         CSDN_Auto_Comment
// @namespace    http://maxcool.buzz
// @version      0.1
// @description  CSDN一键点赞评论(学习)
// @author       maxcool
// @match        https://blog.csdn.net/*/article/details/*
// @include		 https://blog.csdn.net/*/article/details/*
// @exclude		 https://blog.csdn.net/weixin_54858833/article/details/*
// @grant        none
// ==/UserScript==
(function() {
    'use strict';

      var styleMap = {
        display: "inline-block",
        "background-color": "red",
        cursor: "pointer",
        "user-select": "none",
        "min-width": "74px",
        height: "28px",
        "border-radius": "16px",
        color: "#fff",
        "font-size": "14px",
        "line-height": "28px",
        "text-align": "center",
        padding: "0px 10px",
        "margin-left": "16px",
      };
      var commentList = [
          "针不戳呀,写的针不戳!",
          "分享技术,不错哦!",
          "大佬牛批,写的很详细!",
          "感谢博主,你的文章让我得到一些收获!( ̄ˇ ̄)",
      ];

  var randomNum = Math.random() * 4;
  console.log("randomNum", ~~randomNum);

     // 移除广告
     var ad = document.querySelector("#recommendAdBox");
    ad.parentNode.removeChild(ad)

      // 创建按钮
      var btn = document.createElement("div");
      btn.innerHTML = "一键点赞评论";

      // 添加样式
      for (let i in styleMap) {
        btn.style[i] = styleMap[i];
      }

      // 添加点击事件
      btn.addEventListener("click", clickBtn);

      function clickBtn() {

        var isLike = document.querySelector("#is-like");
        isLike.click();

        var comment_content = document.querySelector("#comment_content");
        comment_content.click();
        comment_content.value = commentList[~~randomNum];

        var submit = document.querySelector("[value='发表评论']");
        submit.click();
      }

      var toolbox = document.querySelector(".toolbox-right");

      // 追加到 toolbox
      toolbox.appendChild(btn);
})();