// ==UserScript== // @name Jz Warlight // @namespace https://greasyfork.org/en/users/44200-jz // @version 1.2.4 // @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. Allows note-taking in games. A couple of easter eggs are also included. // @downloadURL none // ==/UserScript== main(); function main() { try{ setupSettings(); var filter_setting = localStorage.getItem('setting_extra_filters'); if(pageIsDashboard()) { if(filter_setting == 'true') { //$("#MyGamesFilter").append(''); $("#MyGamesFilter").append(''); $("#MyGamesFilter").append(''); } } if(pageIsTournaments()) { var muli_setting = localStorage.getItem('setting_enhance_muli'); if(muli_setting == 'true') { var hideNonesButton = $(''); hideNonesButton.on("click", function () { var tds = $("td .tournamentData"); for(var i = 0; i < tds.length; i++) { var td = tds[i]; if(td.innerHTML.indexOf('Games left: None
') > 0) { var parentTr = $(td).parent('tr'); parentTr.hide(); } } }); $("#MyTournamentsTable h2").after(hideNonesButton); } } if(pageIsPastTournaments()) { if(filter_setting == 'true') { //$("#Filter").append(''); $("#Filter").append(''); //$("#Filter").append(''); //$("#Filter").append(''); } } if(pageIsGame()) { var note_setting = localStorage.getItem('setting_enable_notes'); if(note_setting == 'true') { setupNotes(); } } if(pageIsForum()) { // The following code was taken from Master of the Dead's blacklist script and modified to allow me to personally troll him var troll_setting = localStorage.getItem('setting_troll_motd'); var forumPosts = $("#MainSiteContent").find("table:first").find("table"); forumPosts.find("tr").each(function(i, post){ var tdCell = $(post).find("td:first"); var authorCell = tdCell.find('a[href*="/Profile?p="]').first(); if(authorCell !== undefined && authorCell != null){ var postAuthor = authorCell.attr("href"); var date = new Date(); if(postAuthor != null && postAuthor.indexOf('2428496679') != -1) { if(troll_setting == 'true') { if(date.getFullYear() == 2016 && date.getMonth() == 9 && date.getDate() == 17) { changeAvatar(tdCell, "https://lh3.googleusercontent.com/-iDzlv7IG4rY/AAAAAAAAAAI/AAAAAAACsik/FnDXDKxLt5I/s0-c-k-no-ns/photo.jpg"); } else { changeAvatar(tdCell, "http://icons.iconarchive.com/icons/giannis-zographos/english-football-club/256/Liverpool-FC-icon.png"); } if(tdCell.html() != null) { tdCell.html(tdCell.html().replace('Level 62', 'Level 26')); tdCell.html(tdCell.html().replace('Level 63', 'Level 36')); } } } if(postAuthor != null && postAuthor.indexOf('1552135718') != -1) { if(troll_setting == 'true') { if(date.getFullYear() == 2016 && date.getMonth() == 9 && date.getDate() == 17) { changeAvatar(tdCell, "http://icons.iconarchive.com/icons/giannis-zographos/english-football-club/256/Liverpool-FC-icon.png"); } else { changeAvatar(tdCell, "https://lh3.googleusercontent.com/-iDzlv7IG4rY/AAAAAAAAAAI/AAAAAAACsik/FnDXDKxLt5I/s0-c-k-no-ns/photo.jpg"); } if(tdCell.html() != null) { tdCell.html(tdCell.html().replace('Level 58', 'Level 85')); tdCell.html(tdCell.html().replace('Level 59', 'Level 95')); } } } } }); } var extra_features = localStorage.getItem('setting_extra_features'); if(extra_features == 'true' && testDate()) { console.log(new Date()); } } catch(err) { console.log(err); } } function setupSettings() { // Menu item is a modification from Muli's userscript: https://greasyfork.org/en/scripts/8936-tidy-up-your-dashboard $("#TopRightDropDown .dropdown-divider").before('
  • Jz\'s Userscript
  • '); addStyle(".jz-userscript-menu", "display: block;color: #555;text-decoration: none;line-height: 18px;padding: 3px 15px;margin: 0;white-space: nowrap;"); addStyle(".jz-userscript-menu:hover", "cursor:pointer;background-color: #08C;color: #FFF;cursor: pointer;"); var settings_dialog = $('
    '); addSetting(settings_dialog, "Enable Special Features", "setting_extra_features", "false", "Enable the secret easter egg features"); addSetting(settings_dialog, "Enable Note Taking", "setting_enable_notes", "true", "Allow note taking in games"); addSetting(settings_dialog, "Add extra filters", "setting_extra_filters", "true", "Add extra filters to the dashboard and past tournaments pages"); addSetting(settings_dialog, "Add features to enhance Muli's userscript", "setting_enhance_muli", "true", "If muli's script is installed, add features to enhance it."); addSetting(settings_dialog, "Master of the Dead deserves to be trolled", "setting_troll_motd", "true", "He insulted my trollhood, and so he deserves to be trolled."); //addStyle(".jz-userscript-menu img", "height: 18px;display: inline-block;position: relative;margin-bottom: -5px;margin-right: 7px;"); $(".jz-userscript-menu").on("click", function () { settings_dialog.dialog(); }); } function addSetting(settings_dialog, label, id, default_val, title) { var setting_header = $(''); var setting = $(''); settings_dialog.append(setting_header); settings_dialog.append(setting); settings_dialog.append($('
    ')); var stored_value = localStorage.getItem(id); if(stored_value == null) { stored_value = default_val; localStorage.setItem(id, default_val); } if(stored_value == 'true') { setting.prop('checked', true); } setting.on('change', function() { if(setting.prop('checked')) { localStorage.setItem(id, 'true'); } else { if(id == 'setting_troll_motd') { alert('Fool, change your settings, Master of the Dead DOES need to be trolled.'); } localStorage.setItem(id, 'false'); } }); } /** * Create a CSS selector * Taken from Muli's Userscript and renamed from createSelector (to avoid conflict): https://greasyfork.org/en/scripts/8936-tidy-up-your-dashboard * @param name The name of the object, which the rules are applied to * @param rules The CSS rules */ function addStyle(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); } } function setupNotes() { // Add the notes header var notesHeader = $('Notes'); $("#SubTabRow").append(notesHeader); // Parse the gameid var gameid = getGameID(); // Create the popup for the notes var gameNotes = $('