Greasy Fork

来自缓存

Greasy Fork is available in English.

Gamdom Rain Checker

rainchecker for gamdom.com

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Gamdom Rain Checker
// @namespace   https://twitter.com/DasTr0nYx
// @match       https://gamdom.com/*
// @include     https://gamdom.com/*
// @version     0.0.1
// @description rainchecker for gamdom.com
// ==/UserScript==
/*
    This Script sends you a Desktop Notification if Rain is coming. Not working 100%, therefor version 0.0.1
    100% legit and 100% no scam
*/
var MutationObserver = window.MutationObserver;
var myObserver       = new MutationObserver (mutationHandler);
var obsConfig        = {
    childList: true, attributes: true,
    subtree: true,   attributeFilter: ['class']
};
Notification.requestPermission();
function addObserverIfDesiredNodeAvailable() {
    var chatBox = document.getElementById("chat");
    if(!chatBox) {
        window.setTimeout(addObserverIfDesiredNodeAvailable,500);
        return;
    }
    myObserver.observe(chatBox,obsConfig);
}

addObserverIfDesiredNodeAvailable();

function mutationHandler (mutationRecords) {
    mutationRecords.forEach ( function (mutation) {
        if (    mutation.type               == "childList"
            &&  typeof mutation.addedNodes  == "object"
            &&  mutation.addedNodes.length
        ) {
            for (var J = 0, L = mutation.addedNodes.length;  J < L;  ++J) {
                checkForCSS_Class (mutation.addedNodes[J], "rain-message");
            }
        }
        else if (mutation.type == "attributes") {
            checkForCSS_Class (mutation.target, "rain-message");
        }
    } );
}

function checkForCSS_Class (node, className) {
    if (node.nodeType === 1) {
        if (node.classList.contains (className) ) {
            var details = {
                body: "rain incoming! Hurry up",
                icon: 'https://github.com/malachi26/ReviewQueueNotifier/raw/master/Resources/Icon2.jpg'
            };
            var n = new Notification("new Rain", details );
            setTimeout(n.close.bind(n), 10000);
        }
    }
}