Auto reload stake

Auto reload on stake!

目前為 2024-02-20 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Auto reload stake
// @namespace    http://tampermonkey.net/
// @version      1.1.0
// @description  Auto reload on stake!
// @author       FCFC
// @icon         https://www.google.com/s2/favicons?sz=64&domain=stake.com
// @match        https://stake.com/zh?tab=reload&modal=vip*
// @match        https://stake.com/*?tab=reload&modal=vip*
// @require      http://libs.baidu.com/jquery/2.0.0/jquery.min.js
// @grant GM_getValue
// @grant GM.setValue
// @grant GM_setClipboard
// @grant GM_addValueChangeListener
// @grant GM_deleteValue
// @grant GM_log
// ==/UserScript==

(function() {
    'use strict';
    var $ = $ || window.$;
    $(function(){
        var version = '1.0.0'
        // 获取网站域名
        var websiteOrigin = window.location.origin
        console.log('获取网站域名', websiteOrigin)
        setInterval(function() {
            window.location.replace(websiteOrigin + "/zh?tab=reload&modal=vip&currency=trx")
        }, 5*60*1000)

        setInterval(function() {
            document.querySelectorAll("button[type='submit']")[0].click()
        }, 15000)

        /**
         * 添加插件UI到页面的方法
         */
        function controlAction() {
            var html = `<div id="drop-status" style="position:fixed;right: 10px;top:508px;width:50px;height:30px;text-align:center;line-height:30px;border-radius:2px;background:green;color:#fff;font-size:12px;cursor:pointer;z-index:10000">日志</div>
                        <div id="autoDropwrap" style="position:fixed;top:205px;left:60px;z-index:1000000;background:rgba(0,0,0,.5);border-radius:5px;">
                            <div style="padding:10px;background:#213743;margin:0 auto;border-radius:5px;border:1px solid #000;">
                                 <div style="display:flex;align-items:center;justify-content: space-between;">
                                     <div style="font-size:14px;font-weight:bold;color:#fff">Auto claim reload<span class="version"></span></div>
                                 </div>
                                 <div style="font-size:12px;margin-top:10px;">累计领取:<span class="totle-reload" style="color:#0D8A1C;margin-right:20px">0</span>未结算:<span class="nosettle-reload" style="color:red;">0</span></div>
                                 <textarea class="log scrollY" cols="50" rows="20" readonly value="" style="padding:5px;margin-top:10px;font-size:12px;background:#0F212E;border-radius:4px;outline: none;font-family:auto;"></textarea>
                                 <div style="margin-top:15px;display: flex;justify-content: space-between;font-size:12px">
                                     <button class="clear-log" style="background:red;color:#fff;width:90px;border-radius:5px;padding:4px 10px;">删除日志</button>
                                     <button class="clear-total" style="background:red;color:#fff;width:90px;border-radius:5px;padding:4px 10px;">删除总额</button>
                                     <button class="clear-nosettle" style="background:red;color:#fff;width:90px;border-radius:5px;padding:4px 10px;">删除未结算</button>
                                 </div>
                             </div>
                       </div>
            `
            $('body').append(html)
            $('#drop-status').click(function(){
                $('#autoDropwrap').toggle()
            })
            $('#autoDropwrap .version').text('V' + version)
            logger('init')
            countReload(0)
            // 删除数据
            $('#autoDropwrap .clear-log').click(function(){
                GM_deleteValue('Relod_log_text')
                $('#autoDropwrap .log').val('')
            })
            $('#autoDropwrap .clear-total').click(function(){
                GM_deleteValue('Reload_count')
                $('#autoDropwrap .totle-reload').text(0)
            })
            $('#autoDropwrap .clear-nosettle').click(function(){
                GM_deleteValue('Reload_count_no_settle')
                $('#autoDropwrap .nosettle-reload').text(0)
            })
        }
        controlAction()
        /**
         * 更新日志方法
         */
        function logger(text){
            let date = new Date()
            let year = date.getFullYear()
            let month = date.getMonth() + 1
            let day = date.getDate()
            let hour = date.getHours() >=10 ? date.getHours() : `0${date.getHours()}`
            let min = date.getMinutes() >=10 ? date.getMinutes() : `0${date.getMinutes()}`
            let second = date.getSeconds() >=10 ? date.getSeconds() : `0${date.getSeconds()}`
            /*
            let timeStr = date.getTime()
            let timeStr1 = new Date(`${year}-${month}-${day} ${hour}:${min}:${second}`).getTime()
            let haomiao = timeStr - timeStr1 >= 100 ? timeStr - timeStr1 : `0${timeStr - timeStr1}`
            */
            let time = `${month}-${day} ${hour}:${min}:${second}`
            let mark = `${time} | `
            if (text == 'init') {
                let gm_text = GM_getValue('Relod_log_text')
                if (gm_text) {
                    GM_setValue('Relod_log_text',gm_text)
                    $('#autoDropwrap .log').val(gm_text)
                    $('#autoDropwrap .log').scrollTop(100000)
                }
            } else {
                let gm_text = GM_getValue('Relod_log_text')
                if (gm_text) {
                    gm_text+= `${mark}${text}\n`
                } else {
                    gm_text = `${mark}${text}\n`
                }
                GM_setValue('Relod_log_text',gm_text)
                $('#autoDropwrap .log').val(gm_text)
                $('#autoDropwrap .log').scrollTop(100000)
            }
        }
        function countReload(amount) {
            console.log('数据统计')
            let gm_amount = GM_getValue('Reload_count')
            if (gm_amount) {
                gm_amount = Number(gm_amount) + Number(amount)
            } else {
                gm_amount = amount
            }
            gm_amount = gm_amount.toFixed(8)
            console.log('总金额:' + gm_amount)
            GM_setValue('Reload_count', gm_amount)
            $('#autoDropwrap .totle-reload').text(gm_amount)
            // 未结算
            let gm_amount_no_settle = GM_getValue('Reload_count_no_settle')
            if (gm_amount_no_settle) {
                gm_amount_no_settle = Number(gm_amount_no_settle) + Number(amount)
            } else {
                gm_amount_no_settle = amount
            }
            gm_amount_no_settle = gm_amount_no_settle.toFixed(8)
            console.log('未结算金额:' + gm_amount_no_settle)
            GM_setValue('Reload_count_no_settle', gm_amount_no_settle)
            $('#autoDropwrap .nosettle-reload').text(gm_amount_no_settle)
        }
        /**
	     * 重载fetch,用于拦截网页发送的fetch请求
         reload": {
                        "id": "b10e4aa9-dcfb-4214-82ab-ffed1879ec9a",
                        "amount": 0.16028000275361046,
                        "active": true,
                        "claimInterval": 600000,
                        "lastClaim": "Sun, 11 Feb 2024 13:53:56 GMT",
                        "expireAt": "Tue, 13 Feb 2024 06:15:00 GMT",
                        "createdAt": "Tue, 06 Feb 2024 06:15:47 GMT",
                        "updatedAt": "Tue, 06 Feb 2024 06:15:47 GMT",
                        "__typename": "Faucet"
                    },
	     */
        let originFetch = fetch;
        window.unsafeWindow.fetch = async function (...args) {
            const url = args[0]
            const response = await originFetch(...args);
            if (args[1].body) {
                let requestBody = JSON.parse(args[1].body)
                if (url.indexOf('_api/graphql') > -1 && requestBody.query && requestBody.query.indexOf('ClaimFaucet')){
                    let currency = requestBody.variables.currency
                    await response.clone().json().then(res => {
                        console.log('日奖金结果', res)
                        if (res.data) {
                            let reload = res.data.claimReload.reload.user.reload
                            let amount = reload.amount.toFixed(8)
                            console.log(`成功领取 ${amount} ${currency}`)
                            logger(`成功领取 ${amount} ${currency}`)
                            countReload(amount)
                        }
                    }).catch(e=> {
                        console.log('处理返回数据出错:', e)
                    });
                }
            }
            return response;
        }
    })
    // Your code here...
})();