CSDN_Auto_Comment

CSDN一键点赞评论(学习)

  1. // ==UserScript==
  2. // @license MIT
  3. // @name CSDN_Auto_Comment
  4. // @namespace http://maxcool.buzz
  5. // @version 0.1
  6. // @description CSDN一键点赞评论(学习)
  7. // @author maxcool
  8. // @match https://blog.csdn.net/*/article/details/*
  9. // @include https://blog.csdn.net/*/article/details/*
  10. // @exclude https://blog.csdn.net/weixin_54858833/article/details/*
  11. // @grant none
  12. // ==/UserScript==
  13. (function() {
  14. 'use strict';
  15.  
  16. var styleMap = {
  17. display: "inline-block",
  18. "background-color": "red",
  19. cursor: "pointer",
  20. "user-select": "none",
  21. "min-width": "74px",
  22. height: "28px",
  23. "border-radius": "16px",
  24. color: "#fff",
  25. "font-size": "14px",
  26. "line-height": "28px",
  27. "text-align": "center",
  28. padding: "0px 10px",
  29. "margin-left": "16px",
  30. };
  31. var commentList = [
  32. "针不戳呀,写的针不戳!",
  33. "分享技术,不错哦!",
  34. "大佬牛批,写的很详细!",
  35. "感谢博主,你的文章让我得到一些收获!( ̄ˇ ̄)",
  36. ];
  37.  
  38. var randomNum = Math.random() * 4;
  39. console.log("randomNum", ~~randomNum);
  40.  
  41. // 移除广告
  42. var ad = document.querySelector("#recommendAdBox");
  43. ad.parentNode.removeChild(ad)
  44.  
  45. // 创建按钮
  46. var btn = document.createElement("div");
  47. btn.innerHTML = "一键点赞评论";
  48.  
  49. // 添加样式
  50. for (let i in styleMap) {
  51. btn.style[i] = styleMap[i];
  52. }
  53.  
  54. // 添加点击事件
  55. btn.addEventListener("click", clickBtn);
  56.  
  57. function clickBtn() {
  58.  
  59. var isLike = document.querySelector("#is-like");
  60. isLike.click();
  61.  
  62. var comment_content = document.querySelector("#comment_content");
  63. comment_content.click();
  64. comment_content.value = commentList[~~randomNum];
  65.  
  66. var submit = document.querySelector("[value='发表评论']");
  67. submit.click();
  68. }
  69.  
  70. var toolbox = document.querySelector(".toolbox-right");
  71.  
  72. // 追加到 toolbox
  73. toolbox.appendChild(btn);
  74. })();