// ==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
// @downloadURL none
// ==/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¤cy=trx")
}, 5*60*1000)
setInterval(function() {
document.querySelectorAll("button[type='submit']")[0].click()
}, 15000)
/**
* 添加插件UI到页面的方法
*/
function controlAction() {
var html = `
日志
累计领取:0未结算:0
`
$('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...
})();