iCodeReviewHelperAuto

try to take over the world!

  1. // ==UserScript==
  2. // @name iCodeReviewHelperAuto
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.1.2
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://console.cloud.baidu-int.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Your code here...
  15. // 支持从hi直接跳进来唤起
  16. if(!location.href.includes('/reviews/')&&!location.href.includes('/myreview/')) return;
  17. let timer;
  18. const btnNode = document.createElement ('div');
  19. btnNode.id="btns";
  20.  
  21. btnNode.innerHTML=`
  22. <style>
  23. #btns{
  24. position:fixed;
  25. display:flex;
  26. z-index:999;
  27. top:10px;
  28. left:50%;
  29. transform:translateX(-50%);
  30. }
  31. button{
  32. display:block;height:30px;
  33. color:black;
  34. width:110px;
  35. border:none;
  36. outline:none;
  37. }
  38. #p2{
  39. background: #c0dc91;
  40. }
  41. #p1{
  42. background: #eaffee;
  43.  
  44. }
  45. #r1{
  46. background: #fdeff0;
  47.  
  48. }
  49. #r2{
  50. background: #f39ea2;
  51. }
  52. </style>
  53. <button id="r2" >-2(有错误)</button>
  54. <button id="r1" >-1(可读性差)</button>
  55. <button id="p1" >+1(可以更好)</button>
  56. <button id="p2" >+2(完美)</button>
  57. `
  58.  
  59.  
  60.  
  61. // const goodBtnEl = document.querySelector('[ant-click-animating-without-extra-node]');
  62. const getRandomWord = (dict)=>dict[Math.floor(Math.random()*(dict.length))];
  63. const PREFIX = ["这个提交","你的代码"];
  64.  
  65. const PART1 = {
  66. r2:["存在错误"],
  67. r1:["可读性不佳"],
  68. p1: ["基本OK"],
  69. p2:["完美的解决了这个问题", "思路清晰,算法精妙", "让我很有启发", "质量很高"]
  70. }
  71.  
  72.  
  73.  
  74. const CONNECTION = [",请"];
  75.  
  76. const PART2 = {
  77. r2:["修复后再提交"],
  78. r1:["改进一下可读性"],
  79. p1: ["其他同学再看一看吧"],
  80. p2:["继续加油","再接再厉"]}
  81.  
  82.  
  83. document.body.appendChild (btnNode);
  84. const bindEvents = ()=>{
  85. const btnEl = document.querySelector('#btns');
  86. btnEl.addEventListener('click',(e)=>{
  87. console.log(e.target.id);
  88. let buttonId = e.target.id;
  89.  
  90. const panelEl = document.querySelector('[class*="score-score-"]');
  91. panelEl&&panelEl.click();
  92. setTimeout(()=>{
  93. const scoreList = document.querySelectorAll(".ant-popover-inner-content>div>div>div>span")
  94. if(scoreList){
  95. let scoreIndex;
  96. if(buttonId==="p2") {scoreIndex = 4}
  97. else if(buttonId==="p1") {scoreIndex = 3}
  98. else if(buttonId==="r1") {scoreIndex = 1}
  99. else {scoreIndex = 0}
  100.  
  101. const scoreEl = scoreList[scoreIndex];
  102. scoreEl&&scoreEl.click(); // +2
  103. setTimeout(()=>{
  104. const comBoxEl = document.querySelector('[placeholder="在此输入评论"]');
  105. if(comBoxEl){
  106. comBoxEl.value = getRandomWord(PREFIX)+getRandomWord(PART1[buttonId])+getRandomWord(CONNECTION)+getRandomWord(PART2[buttonId]); // 评论
  107. comBoxEl.value&&timer&&clearInterval(timer); // 成功填入,取消自动点
  108. }
  109. },0)
  110. }
  111. },0)
  112.  
  113. })
  114. }
  115.  
  116. bindEvents();
  117.  
  118.  
  119.  
  120.  
  121. // 自动点击
  122. const auto =()=>{
  123. document.onreadystatechange = function () {
  124. if (document.readyState === "complete") {
  125. console.log('ready!');
  126. timer = setInterval(()=>{
  127. btnEl.click();
  128. },1000);
  129. }
  130. }}
  131. })();
  132.  

QingJ © 2025

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