Greasy Fork

Greasy Fork is available in English.

AutoClicker

页面循环自动点击脚本

当前为 2019-01-09 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         AutoClicker
// @namespace    http://gv7.me
// @version      0.1
// @description  页面循环自动点击脚本
// @author       c0ny1,JackyTsuuuy
// @match        https://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

// 多少毫秒点击一次
var cyce = 5000;
// 配置后通过自定义函数获取目标元素
var isCustiom = false;
// 配置后通过id获取目标元素
var id = "";
// 配置后通过name,value获取目标元素
var name = "";
var value = "";
// 配置后通过xpath获取目标元素 e.g: var str_xpath = '//*[@id="su"]';
var str_xpath = '';
// 配置后通过querySelector获取目标元素,e.g: var str_qs = "div .search span a";
var str_qs = ".s_btn_wr input"
/*
	获取点击对象库函数
*/
function getTargetByCustom(){
	return undefined;
}

function getTargetById(t_id){
	var target = document.getElementById(t_id);
    return target;
}


function getTargetByNV(t_name,t_value){
	var target = document.getElementsByName(t_name,t_value);
	for(var i=0;i <target.length;i++){
		if(target[i].value == t_value){
			return target[i];
		}
	}
}


function getTargetByXpath(str_xpath) {
    var xresult = document.evaluate(str_xpath, document, null, XPathResult.ANY_TYPE, null);
    var xnodes = [];
    var xres;
    while (xres = xresult.iterateNext()) {
        xnodes.push(xres);
    }
    return xnodes;
}


function getTargetByQS(str_qs){
    var target = document.querySelector(str_qs);
    return target;
}


function trim(str){
    str = str.replace(/(^\s*)|(\s*$)/g, "");
    return str;
}

/*
	运行流程
*/

var btn;

if(isCustiom === true){
	btn = getTargetByCustom();
}

if(trim(id) !== "" && btn === undefined){
	btn = getTargetById(id);
}

if(trim(name) !== "" && value !== "" && btn === undefined){
	btn = getTargetByNV(name,value);
}

if(trim(str_xpath) !== "" && btn === undefined){
	btn = getTargetByXpath(str_xpath)[0];
}

if(trim(str_qs) !== "" && btn === undefined){
    btn = getTargetByQS(str_qs);
}
window.onload = function(){
	setInterval(function() {
		if (btn !== undefined) {
			btn.click();
		}else{
			console.log('[-] button obj is undefined!');
		}
	},cyce);
}
})();