Greasy Fork

碧蓝幻想手机通知助手

碧蓝幻想副本打完后,手机收到通知

目前为 2023-05-04 提交的版本。查看 最新版本

// ==UserScript==
// @name         碧蓝幻想手机通知助手
// @namespace    muu
// @version      0.4
// @description  碧蓝幻想副本打完后,手机收到通知
// @author       muu
// @license      MIT
// @match        *://game.granbluefantasy.jp/*
// @match        *://gbf.game.mbga.jp/*
// @icon         http://game.granbluefantasy.jp/favicon.ico
// @run-at       document-end
// @grant        GM_notification
// @grant        GM_xmlhttpRequest
// @connect      *
// ==/UserScript==

(function () {
    'use strict';
    var msgChannel = 1//微信=1,qq=2,钉钉=3,discord=4
    var msgUrl = ""//填入得到的链接
    const dingdingData = {
        "msgtype": "text",
        "text": {
            "content": "碧蓝幻想打完了"
        }
    }
    const discordData = {
        "content": "碧蓝幻想打完了"
    }
    window.addEventListener('hashchange', () => {
        let hash = location.hash
        if (/^#result_multi\/\d/.test(hash)) {
            GM_notification({
                title: '碧蓝幻想打完了',
                text: '看一下',
                timeout: 2000
            })
            switch(msgChannel){
                case 3:
                    GM_xmlhttpRequest({
                        method: "POST",
                        url: msgUrl,
                        headers: {
                            "Content-Type": 'application/json;charset=utf-8'
                        },
                        data: JSON.stringify(dingdingData)
                    })
                    break;
                case 4:
                    GM_xmlhttpRequest({
                        method: "POST",
                        url: msgUrl,
                        headers: {
                            "Content-Type": 'application/json;charset=utf-8'
                        },
                        data: JSON.stringify(discordData)
                    })
                    break;
                default:
                    GM_xmlhttpRequest({
                        method: "GET",
                        url: msgUrl
                    })
            }
        }
    })
}());