Greasy Fork

Greasy Fork is available in English.

巴哈姆特哈啦區定時桌面通知

透過Notification函數來將通知顯示於右下角的通知欄位

当前为 2018-11-04 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         巴哈姆特哈啦區定時桌面通知
// @namespace    巴哈姆特哈啦區定時桌面通知
// @description  透過Notification函數來將通知顯示於右下角的通知欄位
// @author       b20100921
// @match        *forum.gamer.com.tw/*
// @version      2018-11-04 01
// @run-at       document-end
// ==/UserScript==
function getNotP() { //第一取得權限
    if (!('Notification' in window)) {
        console.log('This browser does not support notification');
    }
    if (Notification.permission === 'default' || Notification.permission === 'undefined') {
        Notification.requestPermission(function(permission) {
            if (permission === 'granted') {
                var notification = new Notification('開啟通知!', notifyConfig);
            }
        });
    }
}

function opd() {
    var value = parseInt(document.getElementById('topBar_light_0').innerText); //第二開啟通知
    if (value > 0) {
        TOPBAR_show('light_0', 'topb1');
        CatchM();
    }
}

function CatchM() { //第三抓取通知
    var MsgList = document.getElementsByClassName('new');
    TOPBAR_show('light_0', 'topb1');
    for (var MgItems = 0; MgItems < MsgList.length; MgItems++) {
        var notify = new Notification("通知", {
            body: MsgList[MgItems].outerText,
            icon: 'https://m.gamer.com.tw/apple-touch-icon-72x72.png',
            tag: MsgList[MgItems].outerText
        });

    }
}
getNotP();
window.setInterval(function() {
    opd();
    CatchM();
}, 60000); //設定1分鐘更新一次,單位毫秒,60000/1000 = 60秒