// ==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.9.4.1 // @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 showOpenGamesTab; var hideRightColumn; var showOpenGamesFilter; var openGamesFilters; var showGamesActive = "ShowMyGames"; var showAllGames = ""; var showAllCoinGames = ""; var multiOpenGames; var realOpenGames; var bothOpenGames; readLocalstorage(); setGlobalStyles(); setupUserscriptMenu(); if (location.href.match(/.*warlight[.]net\/MultiPlayer.*/)) { /** Show open Games in Tab-Bar * */ if(showOpenGamesTab) { $("#SubTabRow td:nth-child(8)").after('Open Games ') if (location.href.match(/.*warlight[.]net\/MultiPlayer\/OpenGames.*/)) { $("#openGamesTab").addClass("SubTabCellSelected"); $("#openGamesTab").prev().children().css("visibility","visible") $("#openGamesTab").next().children().css("visibility","visible") } } } if (location.href.match(/.*warlight[.]net\/MultiPlayer\/#?$/)) { setupRefresh(); expandGames(); markJoinedGames(); hideBlacklistedThreads(); /** * Open Games Filter */ if (showOpenGamesFilter) { // $("#OpenGamesTable thead tr td").prepend(''); var filters_body = "
"; filters_body += '
'; filters_body += "
"; filters_body += '
'; filters_body += '
'; filters_body += '
'; filters_body += '
'; filters_body += '
'; filters_body += '
'; filters_body += '
'; filters_body += '
'; filters_body += '
More information about Keyword Filtering...
Separate multiple Keywords (3+ letters) with a comma.
The Keyword Filter searches for matches in the complete Gametitle. (Case Insensitive)
Example: Keyword "Rop" removes the Game "Europe 3v3"

'; filters_body += '
'; filters_body += 'minute(s)
'; filters_body += ' day(s) and hour(s)
'; filters_body += '
Close and Apply
'; $("body").append(""); createSelector('.popup input[type="text"]', 'display: inline-block;background: none;border-top: none;border-left: none;border-right: none;color: green;font-size: 15px;border-bottom: 1px white dashed;font-family: Verdana;padding: 0 5px 0 5px;text-align: center;margin-right: 5px'); createSelector('hr', 'height: 1px;border: none;background-color: gray;opacity:0.5;'); createSelector('.number', 'width: 31px'); createSelector('.info', 'font-size: 12px;color: gray;border: 1px gray solid;padding: 5px;display: block;margin: 8px 0 8px 0;line-height: 20px;overflow: hidden; max-height:18px;transition:max-height 2s;-webkit-transition:max-height 2s;'); createSelector('.info:hover', 'max-height:500px'); //createSelector('.info:hover .info-preview', 'display:none'); createSelector('#hideKeyword', 'text-align: left;'); $("#hideLuck").after("%"); //$("#hideRealTimeBootTime").after("minutes"); //$("#hideMultidayTimeBootTime").after("hours"); createSelector('.ui-button-text-only .ui-button-text', 'padding: .4em 0.7em;'); createSelector('#editFilters:hover', 'cursor:pointer'); $(".filters-show").on("change", function () { storeFilterVariables(); }); $("#editFilters").on("click", function () { $(".filters-show").fadeIn(); $(".overlay").fadeIn(); }); $(".close-userscript").on("click", function () { $(".filters-show").fadeOut(); $(".overlay").fadeOut(); refreshAllGames(true); }); $(".close-popup-img").on("click", function () { $(".overlay").fadeOut(); $(".popup").fadeOut(); }); updateFilterSettings(); } /** * 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) { found = true; 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(".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(".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("
" + blogTable.find("thead > tr > td").html() + "
"); realTimeLadderTable.before("
" + realTimeLadderTable.find("thead > tr > td").html() + "
"); forumTable.before("
" + forumTable.find("thead > tr > td").html() + "
"); clanForumTable.before("
" + clanForumTable.find("thead > tr > td").html() + "
"); mapOfTheWeekTable.before("
" + mapOfTheWeekTable.find("thead > tr > td").html() + "
"); leaderboardTable.before("
" + leaderboardTable.find("thead > tr > td").html() + "
"); myTournamentsTable.before("
" + myTournamentsTable.find("thead > tr > td").html() + "
"); createSelector(".followMeBar", "background: #330000;padding: 5px 0px;position: relative;z-index: 1;color: #fff;border-top-right-radius:8px;border-top-left-radius:8px;border: 1px solid gray;border-bottom:none"); var top = parseInt($(".showSide").offset().top) + parseInt(43); createSelector(".followMeBar.fixed", "position: fixed;top: " + top + "px;z-index: 0;z-index:100;"); createSelector(".followMeBar.fixed.absolute", "position: absolute;"); createSelector(".showSide", "overflow-y:scroll;float: left;margin-top: 43px;padding-right: 6px;"); createSelector(".showSide thead", "display:none"); createSelector(".showSide table", "border-top-right-radius:0;border-top-left-radius:0"); /** * Fixed Column CSS */ createSelector("#switchGameRadio label", "margin-left: 6px !important"); createSelector(".showGames table", "display:block !important"); createSelector("#switchGameRadio label:hover", "border: 1px solid rgb(89, 180, 212);border-image-source: initial;border-image-slice: initial;border-image-width: initial;border-image-outset: initial;border-image-repeat: initial;background:rgb(0, 120, 163);font-weight: bold;color: rgb(255, 255, 255);"); createSelector("#MyGamesTable, #PromotedGamesTable, #OpenGamesTable", "display:none"); createSelector("#MainSiteContent > table > tbody > tr > td", "width:100%"); createSelector(".MainColumn", "min-width:535px"); createSelector(".MainColumn", "width:40.55% !important"); createSelector(".SideColumn", "float:left !important"); createSelector("h2 + span", "margin-right: 50px;"); createSelector("body", "overflow:hidden"); createSelector(".SideColumn", "width: 100% !important;"); createSelector("#MyGamesFilter", "width:200px"); createSelector(".showGames table thead", "position:fixed; z-index:500; border-top-left-radius:8px"); createSelector(".showGames table", "display:block; overflow-y:scroll; overflow-x:hidden; border:1px gray solid; border-radius:8px"); createSelector(".adsbygoogle", "margin-top: 25px;"); createSelector(".showSide", "overflow-y:scroll;float: left;margin-top: 43px;padding-right: 6px;width:33.55%; min-width:500px;margin-left: 20px;border-top-left-radius:8px;border-top-right-radius:8px"); createSelector("#refreshAll", "position: absolute;top: 20px;right: 31px"); createSelector("#fakeOpenGameMenu label", "margin-right:2px"); createSelector("#RestoreLotteryGamesBtn", "display:none"); new StickyTitles(jQuery(".followMeBar")).load(); refreshSingleColumnSize(); $("#switchGameRadio").find("label").on("click", function () { var newShowGames = $(this).attr("for"); if (newShowGames != showGamesActive) { $.each($("#switchGameRadio").find("label"), function () { $(this).removeClass("ui-state-active"); }); $(this).addClass("ui-state-active"); if (newShowGames == "ShowMyGames") { showGamesActive = newShowGames; promotedGamesTable.appendTo("body"); openGamesTable.appendTo("body"); myGamesTable.appendTo(".showGames"); } else if (newShowGames == "ShowCoinGames") { showGamesActive = newShowGames; myGamesTable.appendTo("body"); openGamesTable.appendTo("body"); promotedGamesTable.appendTo(".showGames"); } else if (newShowGames == "ShowOpenGames") { showGamesActive = newShowGames; myGamesTable.appendTo("body"); promotedGamesTable.appendTo("body"); openGamesTable.appendTo(".showGames"); } showAllGames.trigger("click"); refreshSingleColumnSize() markJoinedGames(); applyOpenGameFilters(); } }); } /** Hide Right column * */ if(hideRightColumn) { if(scrollGames) { $(".showSide").css("display", "none"); createSelector(".MainColumn", "margin: auto;"); createSelector(".MainColumn", "max-width: 800px;"); createSelector(".MainColumn", "width: 60%!important;"); createSelector(".MainColumn", "float: none !important;"); createSelector(".MainColumn", "min-width: 600px !important;"); } else { $(".SideColumn").css("display", "none"); $(".MainColumn").css("width", "100%"); $(".MainColumn").css("max-width", "800px"); } } $("label[for='MultiDayRadio']").on("click", function () { if (lastClick - new Date() > 2000) { openGamesTable.scrollTop(0); lastClick = new Date(); } markJoinedGames(); }); $("label[for='RealTimeRadio']").on("click", function () { if (lastClick - new Date() > 2000) { openGamesTable.scrollTop(0); lastClick = new Date(); } markJoinedGames(); }); $("label[for='BothRadio']").on("click", function () { if (lastClick - new Date() > 2000) { openGamesTable.scrollTop(0); lastClick = new Date(); } markJoinedGames(); }); $(window).resize(function () { if (scrollGames) { refreshSingleColumnSize(); } }); } if (location.href.match(/.*warlight[.]net\/Discussion/)) { var id = location.href.replace(/.*warlight[.]net\/Discussion\/[?]ID=/, ""); var data = localStorage.getItem('clanForumThreadsTime'); if(data != null) { data = JSON.parse(data) } else { data = []; } var found = false; $.each(data, function(key, val) { if(val.id == id) { data[key] = {id: id, date:new Date()}; found = true; } }); if(!found) { data.push({id: id, date: new Date()}); } localStorage.setItem('clanForumThreadsTime', JSON.stringify(data)) } /** * Reads the User-Settings from Localstorage */ function readLocalstorage() { //Settings scrollGames = localStorage.getItem("scrollGames") == "true"; autoRefreshOnFocus = localStorage.getItem("autoRefreshOnFocus") == "true"; highlightTournaments = localStorage.getItem("highlightTournaments") == "true"; hideMyGamesIcons = localStorage.getItem("hideMyGamesIcons") == "true"; highlightNewForumPosts = localStorage.getItem("highlightNewForumPosts") == "true"; showOpenGamesTab = localStorage.getItem("showOpenGamesTab") == "true"; hideRightColumn = localStorage.getItem("hideRightColumn") == "true"; showOpenGamesFilter = localStorage.getItem("showOpenGamesFilter") == "true"; //Filters var filters = localStorage.getItem("openGamesFilters"); if(filters) { openGamesFilters = $.parseJSON(filters); } else { openGamesFilters = {}; } hideCoinSymbol = true; } /** * Creates the Userscript-Menu */ function setupUserscriptMenu() { var inputs = ""; inputs += '
'; inputs += '
'; inputs += '
'; inputs += '
'; inputs += '
'; inputs += '
'; inputs += '
'; inputs += '
'; inputs += '
Close and Refresh
'; $("body").append(""); $(".userscript-show").on("change", function () { storeSettingsVariables(); }); $("#TopRightDropDown").find("ul").append('
  • Userscript
  • '); $(".userscript-menu").on("click", function () { $(".userscript-show").fadeIn(); $(".overlay").fadeIn(); $("#TopRightDropDown").fadeOut(); }); $(".close-userscript").on("click", function () { $(".userscript-show").fadeOut(); $(".overlay").fadeOut(); location.reload(); }); $(".close-popup-img").on("click", function () { $(".userscript-show").fadeOut(); $(".overlay").fadeOut(); }); checkUserscriptMenuButtons(); } function checkUserscriptMenuButtons() { $("#scrollGames").prop("checked", scrollGames); $("#autoRefreshOnFocus").prop("checked", autoRefreshOnFocus); $("#highlightTournaments").prop("checked", highlightTournaments); $("#hideMyGamesIcons").prop("checked", hideMyGamesIcons); $("#highlightNewForumPosts").prop("checked", highlightNewForumPosts); $("#showOpenGamesTab").prop("checked", showOpenGamesTab); $("#hideRightColumn").prop("checked", hideRightColumn); $("#showOpenGamesFilter").prop("checked", showOpenGamesFilter); } /** * Creates fixed Titles * @param stickies * @constructor */ function StickyTitles(stickies) { var thisObj = this; thisObj.load = function () { stickies.each(function () { var thisSticky = $(this).wrap('
    '); thisSticky.parent().height(thisSticky.outerHeight()); var pos = parseInt(thisSticky.offset().top) - parseInt($(".showSide").offset().top); $.data(thisSticky[0], 'pos', pos); }); $(".showSide").off("scroll.stickies").on("scroll.stickies", function () { thisObj.scroll(); }); }; thisObj.scroll = function () { stickies.each(function (i) { var thisSticky = $(this), nextSticky = stickies.eq(i + 1), prevSticky = stickies.eq(i - 1), pos = $.data(thisSticky[0], 'pos'); var showSide = $(".showSide"); if (pos <= showSide.scrollTop()) { thisSticky.addClass("fixed"); if (nextSticky.length > 0 && thisSticky.offset().top >= $.data(nextSticky[0], 'pos') - thisSticky.outerHeight()) { thisSticky.addClass("absolute").css("top", jQuery.data(nextSticky[0], 'pos') - thisSticky.outerHeight()); } } else { thisSticky.removeClass("fixed"); if (prevSticky.length > 0 && showSide.scrollTop() <= $.data(thisSticky[0], 'pos') - prevSticky.outerHeight()) { prevSticky.removeClass("absolute").removeAttr("style"); } } }); } } jQuery.fn.outerHTML = function (s) { return s ? this.before(s).remove() : jQuery("

    ").append(this.eq(0).clone()).html(); }; /** * Triggers a click on the expand Games Button */ function triggerExpandGames() { if (showAllGames == "" || showAllGames.length == 0) { showAllGames = $("#ShowMoreOpenGamesLink"); showAllGames.trigger("click"); } if (showAllCoinGames == "") { showAllCoinGames = $("#ShowMorePromotedGamesLink"); showAllCoinGames.trigger("click"); } //$("label[for='MultiDayRadio']").trigger("click"); } function markJoinedGames() { var gamesSwitch = setInterval(function(){ applyOpenGameFilters(); var name = $(".TopRightBar a:nth-of-type(2)").text(); var playerLabel = ' You already joined' $.each($("#OpenGamesTable tr"), function(key, tableRow) { $.each($(tableRow).find("span span"), function(key2, player) { if($(player).attr("title") == name && $(tableRow).html().indexOf("You already joined") < 0) { $(tableRow).find("td:nth-of-type(2) a").append(playerLabel) } }); }) }, 5); setTimeout(function() { clearInterval(gamesSwitch); }, 400) } /** * Delayed function for expanding Games */ function expandGames() { numOfGames = 0; styleInterval = setInterval(triggerExpandGames, 100); setTimeout(function () { clearInterval(styleInterval); }, 3000); } /** * Stores User-Settings to local Storage */ function storeSettingsVariables() { localStorage.setItem("autoRefreshOnFocus", $("#autoRefreshOnFocus").prop("checked")); localStorage.setItem("highlightTournaments", $("#highlightTournaments").prop("checked")); localStorage.setItem("hideMyGamesIcons", $("#hideMyGamesIcons").prop("checked")); localStorage.setItem("scrollGames", $("#scrollGames").prop("checked")); localStorage.setItem("highlightNewForumPosts", $("#highlightNewForumPosts").prop("checked")); localStorage.setItem("showOpenGamesTab", $("#showOpenGamesTab").prop("checked")); localStorage.setItem("hideRightColumn", $("#hideRightColumn").prop("checked")); localStorage.setItem("showOpenGamesFilter", $("#showOpenGamesFilter").prop("checked")); } /** * Refreshes Width & Height of Columns */ function refreshSingleColumnSize() { var showSide = $(".showSide"); var showGames = $(".showGames"); showSide.scrollTop(0); /** * Sticky Titles */ $(".followMeBar").each(function () { $(this).removeClass("fixed"); if ($(this).parent().hasClass("followWrap")) { $(this).unwrap(); } var thisSticky = $(this).wrap('

    '); thisSticky.parent().height(thisSticky.outerHeight()); var pos = parseInt(thisSticky.offset().top) - parseInt(showSide.offset().top); $.data(thisSticky[0], 'pos', pos); }); var width = $("#ForumTable").width(); createSelector(".followMeBar", "width:" + width + "px;"); showGames.find("table").css({ height: window.innerHeight - 150 }); showGames.find("table thead").css({ width: showGames.width() - 20 }); var height = showGames.find("table thead").height() + 6; createSelector(".showGames table tbody tr:first-of-type td", "padding-top:" + height + "px"); showSide.css({ height: window.innerHeight - 150 }); showGames.find("table tbody tr:first-of-type td").css("padding-top", showGames.find("table thead").height() + 6) } /** * Create a CSS selector * @param name The name of the object, which the rules are applied to * @param rules The CSS rules */ function createSelector(name, rules) { var style = document.createElement('style'); style.type = 'text/css'; document.getElementsByTagName('head')[0].appendChild(style); if (!(style.sheet || {}).insertRule) { (style.styleSheet || style.sheet).addRule(name, rules); } else { style.sheet.insertRule(name + "{" + rules + "}", 0); } } /** * Reloads all Games */ function refreshAllGames(force) { if($(".popup").is(":visible") && !force) { return; } myGamesTable.find("tbody").fadeTo('slow', 0.15); openGamesTable.find("tbody").fadeTo('slow', 0.15); promotedGamesTable.find("tbody").fadeTo('slow', 0.15); var page = $('
    ').load('https://www.warlight.net/MultiPlayer/ ', function () { var myGames = page.find('#MyGamesTable tbody tr'); //var openGames = page.find('#OpenGamesTable tbody tr'); var promotedGames = page.find('#PromotedGamesTable tbody tr'); showAllGames = page.find("#ShowMoreOpenGamesLink"); promotedGamesTable.find("tbody tr").remove(); $.each(myGamesTable.find("tbody tr"), function (key, value) { if ($(value).html().indexOf("PastGames") == -1) { $(value).remove(); } }); myGamesTable.find("tbody").prepend(myGames); //$("#OpenGamesTable").find("tbody").prepend(openGames); promotedGamesTable.find("tbody").prepend(promotedGames); $("#MorePromotedGamesHorizontalRow").remove(); $("#ShowMorePromotedGamesLinkContainer").remove(); $.each($(".TournamentRow td"), function () { $(this).find("font:first-of-type").appendTo($(this).find("a")).css("font-size", "10px"); }); myGamesTable.find("tbody").fadeTo('slow', 1); //openGamesTable.find("tbody").fadeTo('slow', 1); promotedGamesTable.find("tbody").fadeTo('slow', 1); markJoinedGames(); if (scrollGames) { refreshSingleColumnSize(); openGamesTable.scrollTop(0); myGamesTable.scrollTop(0); promotedGamesTable.scrollTop(0); } }); var activeTab; var active = $("#OpenGamesTable .ui-buttonset .ui-state-active").text(); if (active.indexOf('Both') > -1) { activeTab = "BothRadio"; } else if (active.indexOf('Real') > -1) { activeTab = "RealTimeRadio"; } else { activeTab = "MultiDayRadio"; } //Reload open games var ifr = $('