Greasy Fork

Greasy Fork is available in English.

Genshin Impact & Honkai Impact & Honkai: Star Rail & ZZZ Auto Daily Check-In

Genshin Impact & Honkai Impact & Honkai: Star Rail & Zenless Zone Zero Auto Daily Check-In. Pin daily tab and collect rewards every day you open your browser.

当前为 2024-07-05 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name            Genshin Impact & Honkai Impact & Honkai: Star Rail & ZZZ Auto Daily Check-In
// @namespace       Genshin
// @description     Genshin Impact & Honkai Impact & Honkai: Star Rail & Zenless Zone Zero Auto Daily Check-In. Pin daily tab and collect rewards every day you open your browser.
// @author          NightLancerX
// @match           https://webstatic-sea.mihoyo.com/ys/event/signin-*
// @match           https://webstatic-sea.hoyolab.com/ys/event/signin-*
// @match           https://act.hoyolab.com/ys/event/signin-sea-*
// @match           https://act.hoyolab.com/bbs/event/signin-bh3*
// @match           https://act.hoyolab.com/bbs/event/signin/hkrpg*
// @match           https://act.hoyolab.com/bbs/event/signin/zzz*
// @icon            https://webstatic-sea.mihoyo.com/favicon.ico
// @version         2.4
// @license         MIT License
// @grant           none
// @noframes
// ==/UserScript==

(function(){
    'use strict';
    const REDUCE_OUTPUT = true; //this may help reduce captcha frequency

    let badge;
    setTimeout(function(){
        badge = document.querySelector('[class*=actived-day') ||
                document.querySelector('[class*=signday]') ||
                [...document.querySelector('[class*=components-pc-assets-__prize-list]')?.firstChild.childNodes||[]].filter(e => e.style.backgroundImage.match(/\d+(?=.png)/g) == '6285576485616685271')?.[0]||
					      [...document.querySelector('[class*=components-pc-assets-__prize-list]')?.firstChild.childNodes||[]].filter(e => e.style.backgroundImage.match(/\d+(?=.png)/g) == '3353871917298254056')?.[0];
        if (badge){
          badge.click();
          setTimeout(checkCloseButton, 5000 + Math.random()*2000);
          checkLogin() || setTimeout(checkCaptcha, 2000);
        }
        else if (!REDUCE_OUTPUT) console.log('No badge item');

    }, 12000 + Math.random()*6000);

    function checkCloseButton(){
      let closeBtn = document.querySelector('[class*=---dialog-close]');
      if (closeBtn){
        closeBtn.click();
        if (!REDUCE_OUTPUT) console.log('Checked');
      }
      else{
        if (!REDUCE_OUTPUT) console.log('No close button');
        //let notification = new Notification('Genshin Auto Daily Check-In: can`t verify redeeming, probable delayed captcha');
      }
    }

    function checkLogin(){
      if (document.querySelector('.mhy-account-flow-login')){
        //request initial permission if not granted
        if (Notification.permission != 'granted'){
          document.querySelector('.login-btn').onclick = function(){Notification.requestPermission()};
        }

        //notify afterwards [if granted]
        if (Notification.permission != 'denied'){
          let notification = new Notification('Genshin Auto Daily Check-In: logging required')
        }
        else console.info('Notifications are disabled');

        return true;
      }
    }

    function checkCaptcha(){
      if (document.querySelector('[class^=geetest')){
        let notification = new Notification('Genshin Auto Daily Check-In: completing captcha required')
      }
    }
})();