try to take over the world!
当前为
// ==UserScript==
// @name iCodeReviewHelperAuto
// @namespace http://tampermonkey.net/
// @version 1.2.1
// @description try to take over the world!
// @author You
// @match http://icode.baidu.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
// 支持从hi直接跳进来唤起
if(!location.href.includes('/reviews/')&&!location.href.includes('/myreview/')) return;
let timer;
const btnNode = document.createElement ('div');
btnNode.innerHTML=`
<button id="magic-button" style="position:fixed;left:0;top:50%;width:100px;height:30px;">+2</button>
`
document.body.appendChild (btnNode);
const btnEl = document.querySelector('#magic-button');
// const btnEl = document.querySelector('[ant-click-animating-without-extra-node]');
const A = ["这个提交","你的代码"];
const B = ["完美的解决了这个问题!", "思路清晰,算法精妙!", "让我很有启发!", "质量很高!"]
const C = ["请" ,"希望"];
const D = ["继续加油","再接再厉","继续保持"];
const getRandomWord = (dict)=>dict[Math.floor(Math.random()*(dict.length))];
btnEl.addEventListener('click',()=>{
const panelEl = document.querySelector('[class*="score-score-"]');
panelEl&&panelEl.click();
const scoreList = document.querySelectorAll(".ant-popover-inner-content>div>div>div>span")
if(scoreList){
const score2 = scoreList[scoreList.length - 2];
score2&&score2.click(); // +2
setTimeout(()=>{
const comBoxEl = document.querySelector('[placeholder="在此输入评论"]');
if(comBoxEl){
comBoxEl.value = getRandomWord(A)+getRandomWord(B)+getRandomWord(C)+getRandomWord(D); // 评论
comBoxEl.value&&timer&&clearInterval(timer); // 成功填入,取消自动点
}
},200)
}
})
// 自动点击
document.onreadystatechange = function () {
if (document.readyState === "complete") {
console.log('ready!');
timer = setInterval(()=>{
btnEl.click();
},500);
}
}
})();