// ==UserScript==
// @name Jz Warlight
// @namespace https://greasyfork.org/en/users/44200-jz
// @version 1.2.5
// @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==
// More alts to come
var nauzhror = ['2529731725', // Good Kid
'2920026449', // Omniscient
//'6516195490', // nauzhror
'6563693005', // Larkinator
'6976775032', // ShayLaren
'9520447453', // Purple Illusions
'5617569565', // Scorched Earth
'6052693874', // MasterOfWarZone
'1679264405' // DrunkPlayer
];
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') {
// Add filters for tournaments, to expand the functionality Muli provided
var filter = $('');
filter.append($(''));
filter.append($(''));
filter.append($(''));
filter.append($(''));
filter.append($(''));
filter.append($(''));
filter.on("change", function () {
var selected = $( this ).val();
var tds = $("td .tournamentData");
for(var i = 0; i < tds.length; i++) {
var td = tds[i];
var parentTr = $(td).parent('tr');
if(selected == "showAll") {
parentTr.show();
} else if(selected == "showGamesLeft") {
if(td.innerHTML.indexOf('Games left: None
') > 0) {
parentTr.hide();
} else {
parentTr.show();
}
} else if(selected == "showInProgress") {
if(td.innerHTML.indexOf('Playing: 0
') > 0) {
parentTr.hide();
} else if(td.innerHTML.indexOf('Playing:') > 0) {
parentTr.show();
} else {
parentTr.hide();
}
} else if(selected == "showNotEliminated") {
// Show round robins, tournaments with games in progress, and tournaments with games left
if(parentTr.html().indexOf('Round robin tournament') >= 0) {
parentTr.show();
} else if(td.innerHTML.indexOf('Playing:') > 0
&& td.innerHTML.indexOf('Playing: 0
') == -1) {
parentTr.show();
} else if(td.innerHTML.indexOf('Games left: None
') == -1) {
parentTr.show();
} else {
parentTr.hide();
}
} else if(selected == "showAlmostDone") {
if(td.innerHTML.indexOf('Almost done') > 0) {
parentTr.show();
} else {
parentTr.hide();
}
} else if(selected == "showCoin") {
if(parentTr.html().indexOf('https://d2wcw7vp66n8b3.cloudfront.net/Images/Coins/SmallCoins.png') != -1) {
parentTr.show();
} else {
parentTr.hide();
}
}
}
});
$("#MyTournamentsTable h2").after(filter);
}
}
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 poster_cell = getPosterAnchor(tdCell);
var poster_id = getPosterId(poster_cell);
if(troll_setting == 'true' && poster_id == '2428496679') {
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(troll_setting == 'true' && (poster_id == '1552135718' || poster_id == '397429597')) {
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'));
}
}
// Tag all of nauzhror's accounts
for(var nauz_count = 0; nauz_count < nauzhror.length; nauz_count++) {
var nauz_alt = nauzhror[nauz_count];
if(poster_id == nauz_alt) {
var username = poster_cell.html();
poster_cell.html(username + " (nauzhror)");
}
}
});
}
var extra_features = localStorage.getItem('setting_extra_features');
if(extra_features == 'true' && testDate()) {
console.log(new Date());
}
} catch(err) {
console.log(err);
}
}
function getPosterAnchor(tdCell) {
var posterCell = tdCell.find('a[href*="/Profile?p="]').first();
return posterCell;
}
function getPosterId(posterCell) {
if(posterCell !== undefined && posterCell != null){
var postAuthor = posterCell.attr("href");
if(postAuthor != null && postAuthor.length > 11) {
return postAuthor.substring(11);
}
}
return null;
}
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('