bilibili自动签到

bilibili自动签到 本脚本只支持ScriptCat使用,还在测试中,内测群:887697472

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         bilibili自动签到
// @description  bilibili自动签到 本脚本只支持ScriptCat使用,还在测试中,内测群:887697472
// @namespace    CodFrm
// @version      1.1.2
// @author       wyz
// @crontab * * once * *
// @grant GM_xmlhttpRequest
// @grant GM_notification
// @match http://localtion/undefind
// @connect api.bilibili.com
// @connect api.live.bilibili.com
// @supportURL   https://bbs.tampermonkey.net.cn/forum.php?mod=viewthread&tid=370
// @homepage     https://bbs.tampermonkey.net.cn/forum.php?mod=viewthread&tid=370
// ==/UserScript==

return new Promise((resolve, reject) => {
    GM_xmlhttpRequest({
        method: 'GET',
        url: 'https://api.bilibili.com/x/web-interface/nav',
        onload: function (xhr) {

            switch (xhr.response.code) {
                case 0:
                    GM_xmlhttpRequest({
                        method: 'GET',
                        url: 'https://api.live.bilibili.com/sign/doSign',
                        onload: function (xhr) {

                            switch (xhr.response.code) {
                                case 0:
                                    GM_notification('哔哩哔哩直播自动签到成功');
                                    break;
                                case 1011040:
                                    GM_notification({
                                        title: 'bilibili自动签到 - ScriptCat',
                                        text: '重复签到',
                                    });
                                    break;
                                default:
                            }
                            resolve('B站签到完成');

                        }
                    });
                    break;
                case -101:
                    GM_notification({
                        title: 'bilibili自动签到 - ScriptCat',
                        text: '哔哩哔哩签到失败,账号未登录,请先登录',
                    });
                    break;
                default:

            }

        },
        onerror: function () {
            GM_notification({
                title: 'bilibili自动签到 - ScriptCat',
                text: '网络错误,bilibili签到失败',
            });
            reject('网络错误,bilibili签到失败');
        }
    });

});