// ==UserScript== // @name Jz Warlight // @namespace https://greasyfork.org/en/users/44200-jz // @version 1.2.1 // @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 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(); } } 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"); //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 { 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 = $('