Greasy Fork

Greasy Fork is available in English.

mine

try to take over the world!

当前为 2020-10-13 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         mine
// @namespace    http://tampermonkey.net/
// @version      0.0.0.2
// @description  try to take over the world!
// @author       LaoTie
// @match        https://www.element3ds.com/plugin.php?id=yw_mine:front&mod=mineDetail&mineId=*
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

(async function() {
    'use strict';
    var mineinfo={}
    await start();
    await getStartTime(mineinfo);
    await GM_setObject(mineinfo.mineid,mineinfo)
    console.log("gm_getobject:"+JSON.stringify(await GM_getObject(mineinfo.mineid)))
    setInterval(function(){
        console.log('time is over!')
        window.location.reload()
    },1800000);
})();
//开始时间
async function getStartTime(mineinfo){
    mineinfo.mineid=getQuery('mineId')
    jQuery('.yun_mine_detail div span').each(function(i,e){
        if(i==5){//获取矿工数量
            if(e.innerHTML>0){
                mineinfo.worker=e.innerHTML
            }
        }
        if(i==8){//获取到期时间
            if(e.innerHTML.indexOf('到期')>0){
                mineinfo.endtime=e.innerHTML.replace(' 到期',':30')
            }
        }
    })
}
//开始采矿
async function start(){
    let cangku={}
    cangku.lingqu=[];
    let list=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[0].innerHTML!='480'){
                        let name=list[i].children[j].children[1].innerHTML
                        let cminfo={};
                        cminfo.name=name;
                        cminfo.ele=list[i].children[j].children[1];
                        cangku.lingqu.push(cminfo);
                    }
                }
            }
        }
    }
   firstclick(cangku.lingqu);
}
//执行收取操作
async function firstclick(eles){
    console.log('开始采集');
    for(let i=0;i<eles.length;i++){
        if(eles[i].name=='领取'){
            getMine(eles[i]);
            await sleep(3000);
        }
    }
    for(let i=0;i<eles.length;i++){
        if(eles[i].name=='出售'){
            getMine(eles[i]);
            await sleep(3000);
        }
    }
    console.log('结束采集')
}
//执行确认操作
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')
    console.log(buts)
    if(buts.length>0){
        console.log(buts[0].value)
        buts[0].click()
        await sleep(1000) //
        jQuery('#enter').click()
    }
    console.log('getMine:结束了');
}
//找到目标元素
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;
}

async function GM_setObject(name, value) {
	if (value instanceof Object) {
		// 使用 JSON.stringify 将值转换为文本。
		GM_setValue (name, JSON.stringify (value));
	}
}

async function GM_getObject(name, undefined) {
	try {
		return JSON.parse (GM_getValue (name, '') || '{}');
	} catch (e) {
		// 如果抓取的数据有误报错就直接返回默认值。
		return undefined;
	}
};