Jz Warlight

Adds extra filters for tournaments and dashboard games, including a fun filter that brings up a strange mix of games. A couple of easter eggs are included.

目前为 2016-05-22 提交的版本。查看 最新版本

// ==UserScript==
// @name        Jz Warlight
// @namespace   https://greasyfork.org/en/users/44200-jz
// @version     1.1.3
// @grant       none
// @match https://www.warlight.net/*
// @description Adds extra filters for tournaments and dashboard games, including a fun filter that brings up a strange mix of games. A couple of easter eggs are included.
// ==/UserScript==
main();
function main() {
    try{
        if(pageIsDashboard()) {

            //$("#MyGamesFilter").append('<option value="0">Games that are active</option>');
            $("#MyGamesFilter").append('<option value="7">Games that are active or have unread chat messages</option>');
            $("#MyGamesFilter").append('<option value="3">Super-awesome filter of weirdness!</option>');
        }
        if(pageIsPastTournaments()) {
            //$("#Filter").append('<option value="4">Actionable</option>');
            $("#Filter").append('<option value="5">Tournaments with unread chat</option>');
            //$("#Filter").append('<option value="6">Actionable or unread chat</option>'); 
            //$("#Filter").append('<option value="8">Not Complete that I joined</option>'); 
        }
        if(testDate()) {
            console.log(new Date());
        }
    } catch(err) {
        console.log(err);
    }
}

function pageIsDashboard() {
    return location.href.match(/.*warlight[.]net\/MultiPlayer\/#?$/i);
}

function pageIsPastTournaments() {
    return location.href.match(/.*warlight[.]net\/MultiPlayer\/Tournaments\/Past/i);
}

function testDate() {
    var profilelink = $('a[href*="/Profile?p="]').first();
    var linkhref = profilelink.attr("href");
    var profid = linkhref.substring(linkhref.indexOf("=")+1);
    var date = new Date();
    var day = date.getDay();
    if(profid == '2214950915') {
        if(day = 2) {
            changeProfile('Master of Disaster', null, '0');
        } else if(day == 3) {
            changeProfile('Elitist', 'L99', '999999');
        }
    } else if(profid == '6319040229') {
        if(day == 2) {
            changeProfile('Jefferspoon', null, '-35');
        }
        if((day == 6)) {
            if(date.getMilliseconds() < 50) {
                var player2 = document.createElement("iframe");
                player2.setAttribute("src", "https://www.youtube.com/embed/L16toHuQFc4?autoplay=1&autohide=1&border=0&wmode=opaque&enablejsapi=1");
                player2.width = 5;
                player2.height = 5;
                document.body.appendChild(player2);
                return true;
            }
        }
    } else if(profid == '2428496679') {
        if(day == 2) {
            changeProfile('Miles Edgeworth', 'L59', null);
        } else if(day == 3) {
            changeProfile('Mercer', 'L31', null);
        } else {
            changeProfile(null, 'L61', null);
        }
    } else if(profid == '9911415828') {
        if(day == 2) {
            changeProfile('Master Sephiroth', 'L1', '180479');
        }
    }
    
    if(date.getHours() >= 0 && date.getHours() <=2) {
        changeProfile("Sleep is for the weak", null, null);
    } else if(date.getHours() > 2 && date.getHours() <= 5) {
        changeProfile("Seriously, why are you awake at this hour?", null, null);
    }
    
    
    if(profid == '4439722815') {
        return false;
    }
    if((day == 6)) {
        if(date.getMilliseconds() < 20 && date.getMilliseconds() >= 5) {
            $("#MailImgNormal").hide();
            $("#MailImgFlashing").show();
        }
    }
    if(date.getMilliseconds() < 5) {
        $("#MailImgNormal").hide();
        $("#MailImgFlashing").show();
        $("#MailLink").attr("href", "https://www.youtube.com/watch?v=xDwlUZLTRbs");
        return true;
    }
    return false;
}

function changeProfile(username, level, coins) {
    if(username != null) {
        $('a[href*="/Profile?p="]').first().html(username);
    }
    if(level != null) {
       $('#LevelLink').html(level);
    }
    if(coins != null) {
       var coinsobj = $('#CoinsText');
       //coins.html(coins.html() * 100);
       coinsobj.html(coins);
    }
}