Greasy Fork is available in English.

YYSHelper

云原神签到助手,向着星辰与深渊

// ==UserScript==
// @name         YYSHelper
// @name:zh-CN   云原神签到助手
// @namespace    http://tampermonkey.net/
// @version      0.3.7
// @description  云原神签到助手,向着星辰与深渊
// @author       浪速之星
// @match        *://*/*
// @icon         data:image/gif;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/4gHYSUNDX1BST0ZJTEUAAQEAAAHIAAAAAAQwAABtbnRyUkdCIFhZWiAH4AABAAEAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAAAADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlkZXNjAAAA8AAAACRyWFlaAAABFAAAABRnWFlaAAABKAAAABRiWFlaAAABPAAAABR3dHB0AAABUAAAABRyVFJDAAABZAAAAChnVFJDAAABZAAAAChiVFJDAAABZAAAAChjcHJ0AAABjAAAADxtbHVjAAAAAAAAAAEAAAAMZW5VUwAAAAgAAAAcAHMAUgBHAEJYWVogAAAAAAAAb6IAADj1AAADkFhZWiAAAAAAAABimQAAt4UAABjaWFlaIAAAAAAAACSgAAAPhAAAts9YWVogAAAAAAAA9tYAAQAAAADTLXBhcmEAAAAAAAQAAAACZmYAAPKnAAANWQAAE9AAAApbAAAAAAAAAABtbHVjAAAAAAAAAAEAAAAMZW5VUwAAACAAAAAcAEcAbwBvAGcAbABlACAASQBuAGMALgAgADIAMAAxADb/2wBDAAQDAwMDAgQDAwMEBAQFBgoGBgUFBgwICQcKDgwPDg4MDQ0PERYTDxAVEQ0NExoTFRcYGRkZDxIbHRsYHRYYGRj/2wBDAQQEBAYFBgsGBgsYEA0QGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBj/wAARCACAAIADASIAAhEBAxEB/8QAHQAAAQQDAQEAAAAAAAAAAAAABwQFBggBAgMACf/EAE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Y1ccVhpfZrUsq7LKR/aYJB5ZxnUOMnL1uoQrtbgNxeve3Ha/aWJdNS66y0XpoZceW2tQU22leO0UAnPdyOeM5yAQ2+EVgOcE1cTY9xV6UluKqhGhMSVe8v3AHNiUoygHslDCwgjdg6Q2dxT4PVK2rJnX3XLjotWsOc/Khw6dG7VuqIU/26Buz+7XnCSTgY8fJDSPaIt6BYKpz0Fw148Tf6YGmIbPZ+7FvmA503ZyAPkdSS8ryhXEDgFxa4fcP3LwvFyFFgNvNxi23UBIdS8sEhpSW921QAJO4geuTjVmeDdRap1KtWbJytKIkZZHiopCFY+Z24HqdAziRxF4RUvhTeVD4cXBcFwVC+Ko1UZqarG7FFNQhxTuzJ+NwqVjcMjHj5lWyufDegH/y9j/6xrSdnW973rHcwsz2kkMQieORV2l1C1KrMgVc1eEtyIVqYPvKU7SpO1WU5645YPTXSVKteXVYNRfq0EvwitTJ96QACpO05GefLVSU1WppQEpqMoJAwAHVch99bfteq/8AEpf/AFlfz13+ViDpKenwP+lKfmZh3i8/j6CttULutynwlyHKvDdKQSlll5K1rPklIPP9PHVS61Jbl1t99oICTgdz4eQA5enLl6a5O1KoPtFp+dJcQeqVuqIP0zpLq24TwdvD8xDrJVXxXi5x4a3LQC//2Q==
// @homepageURL  https://greasyfork.org/zh-CN/scripts/487911-%E4%BA%91%E5%8E%9F%E7%A5%9E%E7%AD%BE%E5%88%B0%E5%8A%A9%E6%89%8B
// @grant        GM_xmlhttpRequest
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

(function() {
    'use strict';
    // 请自行修改token,获取教程:https://gitee.com/z2322739526/yyshelper/blob/master/token%E6%95%99%E7%A8%8B.png
    var yystoken = "";
    // 脚本执行间隔xx分钟
    var dotime = 240; // 请求间隔
    var checktime = 10; // 循环检查间隔,-1表示不检查
    // 云原神签到api
    var yysurl = "https://api-cloudgame.mihoyo.com/hk4e_cg_cn/wallet/wallet/get";
    // 样式添加
    const style = `<style>
    .get{
        position:fixed;
        right:80px;
        bottom:150px;
        background-color:#00a1d6;
        color:white;
        height:50px;
        width:50px;
        border-radius: 10px;
        font-size:15px;
        border:solid 3px #FA5A57;
        cursor:pointer;
        outline: none;
        z-index: 9999;
    }
    .get:hover {
        background-color:#33b4de;
    }
    .help{
        position:fixed;
        right:80px;
        bottom:80px;
        background-color:#00a1d6;
        color:white;
        height:50px;
        width:50px;
        border-radius: 10px;
        font-size:15px;
        border:solid 3px #FA5A57;
        cursor:pointer;
        outline: none;
        z-index: 9999;
    }
    .help:hover {
        background-color:#33b4de;
    }
    .alertMessage{
        position: fixed;
		top: 30px;
		left: 40%;
		right: 40%;
		padding: 20px 30px;
		background: rgba(0, 0, 0, 0.8);
		color: #ffffff;
		font-size: 20px;
		text-align: center;
		z-index: 9999;
		display: none;
        border-radius:5px;
        white-space: pre-wrap;
    }
    </style>`;
    let div = document.createElement("div");
    div.innerHTML += style;
    document.body.append(div);
    // 提示框
    var alertMessage = document.createElement("div");
    alertMessage.classList.add('alertMessage');
    document.body.append(alertMessage);
    function alertmess(mess) {
		alertMessage.innerHTML = mess; // 填入要显示的文字
		alertMessage.style.display = "inline"; // 显示弹框
		setTimeout(function () { // 倒计时
			alertMessage.innerHTML = ''; // 清空文本
			alertMessage.style.display = "none" // 隐藏弹框
		}, 8 * 1000); // 8秒
	}
    function timestampToTime(timestamp) {
        // 时间戳为10位需*1000,时间戳为13位不需乘1000
        var date = new Date(timestamp);
        // var Y = date.getFullYear() + "-";
        // var M =(date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + "-";
        // var D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
        var h = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours())+ ":";
        var m = (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes())+ ":";
        var s = (date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds());
        // return Y + M + D + h + m + s;
        return h + m + s;
    }
    function yysget(){
        yystoken = GM_getValue('yystoken');
        const lastExecutionTime = GM_getValue('myScriptLastExecution');
        GM_xmlhttpRequest({
            url:yysurl,
            method:"get",
            Referer: "https://ys.mihoyo.com/",
            headers:{
                // X-Rpc-Combo_token必须
                "X-Rpc-Combo_token":yystoken,
            },
            onload:function(xhr){
                var data = JSON.parse(xhr.response);
                console.log(data);
                if(data.message == "OK"){
                    console.log("云原神签到成功");
                    console.log("赠送时长:" + data.data.free_time.send_freetime + "分钟");
                    console.log("免费时长:" + data.data.free_time.free_time + "分钟");
                    console.log("免费时长:" + parseInt(data.data.free_time.free_time/60) + "小时" + data.data.free_time.free_time%60 + "分钟");
                    alertmess("云原神签到成功\n赠送时长:" + data.data.free_time.send_freetime + "分钟\n免费时长:" + parseInt(data.data.free_time.free_time/60) + "小时" + data.data.free_time.free_time%60 + "分钟\n上次检查时间:" + timestampToTime(lastExecutionTime))
                } else {
                    console.log("云原神签到失败(秘钥过期)");
                    if(!window.location.href.includes('ys.mihoyo.com/cloud')){
                        var t1 = confirm("云原神签到失败(秘钥过期)\n请点击确认跳转,手动登录更新秘钥");
                        if(t1 == true){
                            window.open('https://ys.mihoyo.com/cloud/#/', '_self');
                        }
                    } else {
                        alertmess("云原神签到失败(秘钥过期)\n请点击获取教程\n参考教程更新秘钥后重试");
                    }
                }
            }
        })
        // 脚本成功执行后,更新执行时间
        GM_setValue('myScriptLastExecution', new Date().getTime());
    }
    function main(){
        console.log("-------- 云原神签到助手 by 浪速之星 --------");
        // 检查上次执行的时间
        const lastExecutionTime = GM_getValue('myScriptLastExecution');
        yystoken = GM_getValue('yystoken');
        console.log("当前秘钥:" + yystoken);
        const now = new Date().getTime(); // 当前时间的时间戳
        // console.log("上次检查时间:" + timestampToTime(lastExecutionTime));
        // 如果上次执行的时间在XX分钟之内
        if (lastExecutionTime && now - lastExecutionTime < dotime * 60 * 1000) {
            console.log("上次检查时间:" + timestampToTime(lastExecutionTime));
            console.log("当前时间:" + timestampToTime(now));
            console.log("云原神签到助手在"+ dotime + "分钟内已执行过,不再重复执行。");
        } else {
            yysget()
        }
    }
    // main
    // 云原神页面添加按钮
    if(window.location.href.includes('ys.mihoyo.com/cloud')){
        // 点击输入token
        var get = document.createElement("input");
        get.setAttribute("type", "button");
        get.setAttribute("title", "右键隐藏");
        get.setAttribute("value", "更新\n秘钥");
        get.classList.add('get');
        document.body.append(get);
        get.onclick = function(){
            yystoken = prompt('请输入您的云原神秘钥(X-Rpc-Combo_token):');
            if(yystoken){
                GM_setValue('yystoken', yystoken);
                alertmess("更新秘钥成功:\n" + yystoken);
            }
        }
        // 跳转获取秘钥教程
        var help = document.createElement("input");
        help.setAttribute("type", "button");
        help.setAttribute("title", "右键隐藏");
        help.setAttribute("value", "获取\n教程");
        help.classList.add('help');
        document.body.append(help);
        help.onclick = function(){
            window.open('https://gitee.com/z2322739526/yyshelper/blob/master/token%E6%95%99%E7%A8%8B.png', '_blank');
        }
        // 强制执行一次,检查秘钥是否可用
        yysget();
        // 右键隐藏按钮
        get.addEventListener("contextmenu", function() {
            get.style.display = "none";
            help.style.display = "none";
        });
        help.addEventListener("contextmenu", function() {
            get.style.display = "none";
            help.style.display = "none";
        });
    }
    main();
    // 每隔XX分钟再循环检查一次
    if(!(checktime == -1)){
        setInterval(main, checktime * 60 * 1000);
    }
})();