iCodeReviewHelperAuto

try to take over the world!

当前为 2019-07-25 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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);
        }
    }
})();