Black Flash's HF Clover Award Notification Script

Get a notification as soon as a green,purple or gold clover award has been given out

目前为 2016-06-07 提交的版本,查看 最新版本

// ==UserScript==
// @name         Black Flash's HF Clover Award Notification Script
// @include     *http://hackforums.net/*
// @namespace    http://hackforums.net/
// @version      1.1
// @description  Get a notification as soon as a green,purple or gold clover award has been given out
// @author       Black Flash ⚡
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @grant       GM_addStyle
// @grant       GM_xmlhttpRequest
// @grant       GM_getValue
// @grant       GM_setValue
// ==/UserScript==

(function() {
    var last_purple = GM_getValue("purple_clover", false);
    var last_gold = GM_getValue("gold_clover", false);
    var last_green = GM_getValue("green_clover", false);
    
    // Set the ones you don't want to false.
    var green = true;
    var purple = true;
    var gold = true;
    
    if(green) {
        GreenCloverAward();
    }
    
    if(purple) {
        PurpleCloverAward();
    }
    
    if(gold) {
        GoldCloverAward();
    }
    
    function GreenCloverAward() {
        $.ajax({
            type: "GET",
            crossDomain: true,
            url: "http://hackforums.net/myawards.php?awid=85",
            dataType: "html",
            success: function(response) {
                var last_entry = $(response).find('tr').last().html();
                var last_award = $(last_entry).find('span').html();
                if (last_award != last_green && last_green !== false) {
                    alert(last_award + " has just gotten the green clover award!");
                    setTimeout(function() {
                        GM_setValue("green_clover",last_award);       
                    }, 0);
                }
            },
            error: function () {
                console.log("FFS");
            }
        });
    }

    function PurpleCloverAward() {
        $.ajax({
            type: "GET",
            crossDomain: true,
            url: "http://hackforums.net/myawards.php?awid=86",
            dataType: "html",
            success: function(response) {
                var last_entry = $(response).find('tr').last().html();
                var last_award = $(last_entry).find('span').html();
                if (last_award != last_purple && last_purple !== false) {
                    alert(last_award + " has just gotten the purple clover award!");
                    setTimeout(function() {
                        GM_setValue("purple_clover",last_award);       
                    }, 0);
                }
            },
            error: function () {
                console.log("FFS");
            }
        });
    }
    
    function GoldCloverAward() {
        $.ajax({
            type: "GET",
            crossDomain: true,
            url: "http://hackforums.net/myawards.php?awid=87",
            dataType: "html",
            success: function(response) {
                var last_entry = $(response).find('tr').last().html();
                var last_award = $(last_entry).find('span').html();
                if(last_award !== "undefined" && last_award !== undefined && last_award !== null && last_gold !== false) {
                    if (last_award !== last_gold) {
                        alert(last_award + " has just gotten the gold clover award! :o");
                        setTimeout(function() {
                            GM_setValue("gold_clover",last_award);       
                        }, 0);
                    }
                }
            },
            error: function () {
                console.log("FFS");
            }
        });
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址