// ==UserScript==
// @name Tidy up your Dashboard
// @namespace https://greasyfork.org/users/10154
// @grant none
// @match https://www.warlight.net/*
// @description Customizable Userscript which tidies up your Dashboard!
// @version 1.7.8
// @icon http://i.imgur.com/XzA5qMO.png
// @downloadURL none
// ==/UserScript==
var lastRefresh;
var styleInterval;
var myGamesTable = $("#MyGamesTable");
var openGamesTable = $("#OpenGamesTable");
var promotedGamesTable = $("#PromotedGamesTable");
var lastClick = new Date();
var scrollGames;
var autoRefreshOnFocus;
var highlightTournaments;
var hideMyGamesIcons;
var hideCoinSymbol;
var highlightNewForumPosts;
var showGamesActive = "ShowMyGames";
var showAllGames = "";
var showAllCoinGames = "";
var multiOpenGames;
var realOpenGames;
var bothOpenGames;
readLocalstorage();
if (location.href.match(/.*warlight[.]net\/MultiPlayer\/#?$/)) {
setupRefresh();
setupUserscriptMenu();
expandGames();
markJoinedGames();
/**
* Hide coin Symbol
*/
if (hideCoinSymbol) {
createSelector('#PromotedGamesTable td:last-of-type a img', 'display:none');
createSelector("#MyGamesTable td > a > img", 'display:none')
}
/**
* Highlight Tournaments
*/
if (highlightTournaments) {
createSelector("#MyTournamentsTable tbody", "background:#4C4C33;");
}
/**
* Hide coin Game Icons
*/
if (hideMyGamesIcons) {
createSelector("#MyGamesTable td div img, #MyGamesTable td div a img", "display:none;");
}
/**
* Highlight Clan Forum Posts
*/
if (highlightNewForumPosts) {
var regex1 = /.* commented [\n \t]+/;
var regex2 = / ago/;
var regex3 = /.*\/Forum\//;
var regex4 = /-.*/;
var data = localStorage.getItem('clanForumThreadsTime');
if(data != null) {
data = JSON.parse(data)
} else if(data == null){
data = [];
$.each($('#ClanForumTable tbody tr'), function (index, row) {
if($(row).find('td a')[0].href.match(/.*Forum\/[0-9]+/)) {
var id = $(row).find('td a')[0].href.replace(regex3, "").replace(regex4, "");
data.push({id: id, date: new Date()});
}
});
localStorage.setItem('clanForumThreadsTime', JSON.stringify(data))
}
$.each($('#ClanForumTable tbody tr'), function (index, row) {
if($(row).find('td a')[0].href.match(/.*Forum\/[0-9]+/)) {
var lastComment = $(row).find('td span').text().trim().replace(regex1, "").replace(regex2, "");
var id = $(row).find('td a')[0].href.replace(regex3, "").replace(regex4, "");
var found = false;
$.each(data, function(key, val) {
if(val.id == id) {
console.log(1)
found = true;
//console.log(val.id + ' ' + new Date(val.date) + ' ' + getDate(lastComment))
if(getDate(lastComment) > new Date(val.date)) {
$(row).css('background', '#4C4C33');
}
}
});
if(!found) {
$(row).css('background', '#4C4C33');
}
}
});
}
/**
* Basic CSS
*/
createSelector(".GameRow a", "font-size:16px !important;");
createSelector(".GameRow td:last-of-type span,#OpenGamesTable .GameRow td:last-of-type span:first-child, #PromotedGamesTable .GameRow td:last-of-type span:first-child", "margin:5px 0px;position:relative !important;z-index:10;");
createSelector("#MyGamesTable td span a img, #MyGamesTable td span a img", "display:inherit;");
createSelector(".GameRow:hover", "background-color:rgb(50, 50, 50);cursor:pointer;");
createSelector(".BootTimeLabel", "color:white !important;font-weight:normal!important;font-style:italic;font-size:13px!important;z-index:50;");
createSelector(".GameRow a:hover", "text-decoration:none;");
createSelector(".TournamentRow a:hover", "text-decoration:none;");
createSelector(".TournamentRow:hover", "background-color:rgb(50, 50, 50);cursor:pointer;");
createSelector(".ui-buttonset label", "font-size:11px;");
createSelector("#OpenGamesTable label:hover", " border: 1px solid #59b4d4;background: #0078a3 50% 50% repeat-x;font-weight: bold;color: #ffffff;");
createSelector("#OpenGamesTable td:last-child,#MyGamesTable td:last-child, #PromotedGamesTable td:last-child", "position: relative;");
createSelector("#OpenGamesTable td:nth-child(2) a,#MyGamesTable td:nth-child(2) a, #PromotedGamesTable td:nth-child(2) a", " display: block;width: 100%;height: 100%;float: left;position: absolute;margin-top: -5px;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;");
createSelector(".loading", "position: absolute;height: 100%;width: 100%;background-color: rgba(255, 255, 255, 0.2);text-align: center;z-index: 12;margin-top: 34px;display:none;");
createSelector(".loading img", "position: absolute;top: 50%;left: 50%;margin-left: -16px;margin-top: -16px;");
createSelector("img", "position: relative;z-index:50;");
createSelector("input", "z-index: 1000;position: relative;");
createSelector(".userscript", "position: fixed;width: 420px;left: 50%;background: #171717;margin-left: -250px;top: 100px;z-index: 50000001; color:white;padding:60px 30px 30px 30px;border: 2px solid gray;border-radius:8px");
createSelector(".userscript-menu", "display: block;color: #555;text-decoration: none;line-height: 18px;padding: 3px 15px;margin: 0;white-space: nowrap;");
createSelector(".userscript-menu:hover", "cursor:pointer;background-color: #08C;color: #FFF;cursor: pointer;");
createSelector(".close-userscript", "margin-top: 40px;width: 100%;text-align: center;font-size: 15px;cursor: pointer;background: gray;line-height: 30px;border-radius: 8px;");
createSelector(".close-userscript-img", "float:right;margin:5px;cursor:pointer");
createSelector(".userscript label", "width: 80%;display: inline-block;font-size: 15px;margin: 5px;");
createSelector(".userscript input", "width: 20px;height: 20px;margin-left:30px;margin: 5px");
createSelector(".userscript-container", "display: block;position: absolute;background: white;top: 0;left: 0;right: 0;bottom: 0;z-index: 50000000;opacity: 0.5;");
createSelector(".userscript .head", "position: absolute;height: 40px;background: #330000;width: 100%;left: 0;right: 0;top: 0;color: white;font-size: 15px;text-align: center;line-height: 40px;border-top-left-radius:8px;border-top-right-radius:8px;");
createSelector(".userscript-show", "display:none");
createSelector(".showGames table thead td", "display:table-cell;width:100%;");
createSelector(".showGames table thead tr", "display:table;width:100%;");
createSelector(".showGames table tbody", "display:table;width:100%;");
$.each($(".TournamentRow td"), function () {
$(this).find("font:first-of-type").appendTo($(this).find("a")).css("font-size", "10px");
});
/**
* Fixed window with Scrollable Games
*/
if (scrollGames) {
var gameButtons = '
';
var mainColumn = $(".MainColumn ");
mainColumn.prepend('
' + gameButtons + '
');
myGamesTable.appendTo(".showGames");
mainColumn.after('');
$(".SideColumn").appendTo(".showSide");
/**
* Fixed Titles in Side Column
*/
var blogTable = $("#BlogTable");
var realTimeLadderTable = $("#RealTimeLadderTable");
var forumTable = $("#ForumTable");
var clanForumTable = $("#ClanForumTable");
var mapOfTheWeekTable = $("#MapOfTheWeekTable");
var leaderboardTable = $("#LeaderboardTable");
var myTournamentsTable = $("#MyTournamentsTable");
blogTable.before("