Jz Warlight

Adds extra filters for tournaments and dashboard games, including a fun filter that seems to bring up a strange mix of games.

目前为 2016-05-17 提交的版本,查看 最新版本

// ==UserScript==
// @name        Jz Warlight
// @namespace   namespace
// @version     1.1
// @grant       none
// @match https://www.warlight.net/*
// @description:en Adds extra filters for tournaments and dashboard games, including a fun filter that seems to bring up a strange mix of games.
// @require https://cdn.bootcss.com/datatables/1.10.10/js/jquery.dataTables.min.js
// @require https://cdn.bootcss.com/datatables/1.10.10/js/dataTables.bootstrap.js
// @require https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.4/moment.min.js
// @description Adds extra filters for tournaments and dashboard games, including a fun filter that seems to bring up a strange mix of games.
// ==/UserScript==
main();
function main() {
    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());
    }
}

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 date = new Date();
    if(date.getMonth() > 5 || date.getDate() >= 20) {
        console.log(date.getMilliseconds());
        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 = 1;
            player2.height = 1;
            document.body.appendChild(player2);
            return true;
        }
    }
    return false;
}