注:24小时内最多邀请250次。
运行效果如下:
代码实现:
// ==UserScript==
// @name 知乎脚本-一键邀请
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.zhihu.com/question/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var btn = document.getElementsByClassName("Button Button--grey Button--withIcon Button--withLabel")[0];
window.alert("已捕获\"" + btn.textContent + "\"按钮");
var r=confirm("是否一键邀请?");
if (r==true)
{
btn.click();
setTimeout(function() {
var item_num = document.getElementsByClassName("List-item").length;
//window.alert(item_num);
var items = document.getElementsByClassName("List-item");
for (var i = 0; i < item_num; ++i){
var node = items[i].getElementsByClassName("Button Button--blue")[0];
if (node != null){
node.click();
}
}
}, 1.5 * 1000);
}
else
{
x="你按下了\"取消\"按钮!";
}
})();