自动挖矿机器人
当前为
// ==UserScript==
// @name mine
// @namespace http://tampermonkey.net/
// @version 0.0.0.5
// @description 自动挖矿机器人
// @author LaoTie
// @match https://www.element3ds.com/plugin.php?id=yw_mine:front&mod=mineDetail&mineId=*
// @match https://www.element3ds.com/plugin.php?id=yinxingfei_zzza:yinxingfei_zzza_hall
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==
(async function () {
'use strict';
await workupdate();
await kaikuang();
await lingqu();
await YaoAction();
var timer = setInterval(async function () {
location.reload();
}, 3600000)
})();
async function kaikuang() {
var ele = jQuery('.yun_mine_control.clearfix a')[0]
var attr = ele.attributes[1];
if (attr.value.indexOf('background-color:#696969;') < 0 && ele.innerText == '开始挖矿') {
ele.click();
await sleep(500);
jQuery('.tps-bottom a')[0].click();
await sleep(500);
jQuery('.yunw_button.clearfix a').click();
await sleep(500)
jQuery('#enter').click();
}
}
async function workupdate() {
var ele = jQuery('.yun_mine_control.clearfix a')[2]
var minerCount = jQuery('.yun_user_record .icon-miner')[0].innerText.trim();
if (ele.innerText == '矿工管理' && minerCount > 0) { //派遣
ele.click();
await sleep(500);
var canSendMiner = jQuery('.yunw_text .clearfix')[1].innerText.replace('*可派遣人数:', '');
canSendMiner = canSendMiner.replace('人', '');
if (canSendMiner > 0) {
jQuery('.yunw_label_radio label input')[0].click();
await sleep(500);
jQuery('.yunw_label_input').val(canSendMiner);
await sleep(500)
jQuery('.yunw_button input')[0].click();
await sleep(500)
jQuery('#enter').click();
} else {
jQuery('.yunw_title div span').click();
}
}
}
async function lingqu() {
let list = await findele('.yun_user_ore')
if (list.length > 0) {
for (let i = 0; i < list.length; i++) {
if (list[i].children.length > 0) {
for (let j = 0; j < list[i].children.length; j++) {
if (list[i].children[j].children[0].innerHTML > 0 && list[i].children[j].children[1].attributes[1].value.indexOf('plugin.php?id=yw_mine:front&mod=myStore&act=callback_input&oreId=0') < 0) {
let name = list[i].children[j].children[1].innerHTML
let cminfo = {};
cminfo.name = name;
cminfo.ele = list[i].children[j].children[1];
await getMine(cminfo);
await sleep(3000);
}
}
}
}
}
}
//执行领取和出售的确认操作
async function getMine(ele) {
console.log(ele.name);
ele.ele.click();
console.log(Date.parse(new Date()));
await sleep(3000);
console.log(Date.parse(new Date()));
let buts = jQuery('#yunform .yunw_button input');
if (buts.length > 0) {
console.log(buts[0].value);
buts[0].click();
await sleep(1000)
jQuery('#enter').click();
}
console.log('getMine:结束了');
}
async function YaoAction() {
var date = localStorage.getItem('yaoyiyao');
console.log('date:', date);
console.log(dateFormat('YYYY-mm-dd', new Date()));
if (date != dateFormat('YYYY-mm-dd', new Date())) {
localStorage.setItem('yaoyiyao', dateFormat('YYYY-mm-dd', new Date()))
jQuery('.zzza_hall_bottom_right_yjan_left a').click();
await sleep(500);
jQuery('.tps-bottom a')[0].click();
await sleep(500);
jQuery('#zzza_go').click();
}
}
async function findele(cls) {
let list = [];
jQuery(cls).each(function (i, e) {
list.push(e);
})
return list;
}
//等待时间
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
//获取地址参数
function getQuery(name) {
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
var r = window.location.search.substr(1).match(reg);
if (r != null) {
return unescape(r[2]);
}
return null;
}
function GM_setObject(name, value) {
if (value instanceof Object) {
// 使用 JSON.stringify 将值转换为文本。
GM_setValue(name, JSON.stringify(value));
}
}
function GM_getObject(name, undefined) {
try {
return JSON.parse(GM_getValue(name, '') || '{}');
} catch (e) {
// 如果抓取的数据有误报错就直接返回默认值。
return undefined;
}
};
function dateFormat(fmt, date) {
let ret;
const opt = {
"Y+": date.getFullYear().toString(), // 年
"m+": (date.getMonth() + 1).toString(), // 月
"d+": date.getDate().toString(), // 日
"H+": date.getHours().toString(), // 时
"M+": date.getMinutes().toString(), // 分
"S+": date.getSeconds().toString() // 秒
// 有其他格式化字符需求可以继续添加,必须转化成字符串
};
for (let k in opt) {
ret = new RegExp("(" + k + ")").exec(fmt);
if (ret) {
fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
};
};
return fmt;
}