Tidy up your Dashboard

Customizable Userscript which tidies up your Dashboard!

当前为 2015-09-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Tidy up your Dashboard
  3. // @namespace https://gf.qytechs.cn/users/10154
  4. // @grant none
  5. // @match https://www.warlight.net/*
  6. // @description Customizable Userscript which tidies up your Dashboard!
  7. // @version 1.9.5.5
  8. // @icon http://i.imgur.com/XzA5qMO.png
  9. /*jslint browser: true, regexp: true*/
  10. /*global $, jQuery*/
  11. // ==/UserScript==
  12.  
  13.  
  14. var version = "1.9.5.1";
  15.  
  16. function checkVersion() {
  17. var currentVersion = localStorage.getItem('version');
  18. if (currentVersion == version) {
  19. //Script Up to date
  20. } else if (currentVersion == undefined) {
  21. //Script new installed
  22. $(".userscript-show").fadeIn();
  23. $(".overlay").fadeIn();
  24. } else {
  25. //Script Updated
  26. // $("label[for='hidePromotedGames']").addClass('newSetting');
  27. // $("label[for='hideCoinsGlobally']").addClass('newSetting');
  28. // $(".userscript-show").fadeIn();
  29. // $(".overlay").fadeIn();
  30. }
  31. localStorage.setItem('version', version);
  32. }
  33.  
  34.  
  35. var lastRefresh;
  36. var delayedFunction;
  37. var myGamesTable = $("#MyGamesTable");
  38. var openGamesTable = $("#OpenGamesTable");
  39. var promotedGamesTable = $("#PromotedGamesTable");
  40. var lastClick = new Date();
  41.  
  42. var openGamesFilters;
  43.  
  44. var userscriptSettings = [
  45. {id: 'scrollGames', text: 'Fixed Window with scrollable Games', selected: false, title: 'Dashboard', addBreak: false},
  46. {id: 'hideMyGamesIcons', text: 'Hide Icons in "My Games"', selected: false, title: '', addBreak: false},
  47. {id: 'autoRefreshOnFocus', text: 'Automatically refresh Games on Tab-Focus', selected: false, title: '', addBreak: false},
  48. {id: 'highlightTournaments', text: 'Highlight Tournament invites', selected: false, title: '', addBreak: false},
  49. {id: 'highlightNewForumPosts', text: 'Highlight new Clan Posts', selected: false, title: '', addBreak: false},
  50. {id: 'hideRightColumn', text: 'Hide Right Column', selected: false, title: '', addBreak: false},
  51. {id: 'showOpenGamesFilter', text: 'Enable Open Games Filter', selected: false, title: '', addBreak: false},
  52. {id: 'hidePromotedGames', text: 'Hide Promoted Games', selected: false, title: '', addBreak: false},
  53. {id: 'useDefaultBootLabel', text: 'Use the Default Boot Time Label', selected: false, title: '', addBreak: false},
  54. {id: 'showOpenGamesTab', text: 'Show Open Games Tab in Menu Bar', selected: false, title: 'Global', addBreak: false},
  55. {id: 'hideCoinsGlobally', text: 'Hide Coins Globally', selected: false, title: '', addBreak: false}
  56. ];
  57.  
  58.  
  59.  
  60. var showGamesActive = "ShowMyGames";
  61.  
  62. //Expand Games Buttons
  63. var showAllGames = "";
  64. var showAllCoinGames = "";
  65.  
  66. var openGames = [];
  67. readLocalstorage();
  68. setGlobalStyles();
  69. setupUserscriptMenu();
  70. checkVersion();
  71.  
  72. $.fn.settingIsEnabled = function (setting) {
  73. var selected = false;
  74. $.each(userscriptSettings, function (key, set) {
  75. if (set.id == setting) {
  76. selected = set.selected;
  77. }
  78. });
  79. return selected;
  80. };
  81.  
  82. if (pageIsMultiplayer()) {
  83. //Show Open Games Link
  84. if (isEnabled('showOpenGamesTab')) {
  85. showOpenGamesLink();
  86. }
  87. }
  88.  
  89. if (pageIsDashboard()) {
  90. setupRefreshFunction();
  91. expandGames();
  92. markJoinedGames();
  93. hideBlacklistedThreads();
  94. setupBasicDashboardStyles();
  95.  
  96. if (isEnabled('showOpenGamesFilter')) {
  97. setupOpenGamesFilter();
  98. }
  99.  
  100. if (isEnabled('highlightTournaments')) {
  101. createSelector("#MyTournamentsTable tbody", "background:#4C4C33;");
  102. }
  103. if (isEnabled('hidePromotedGames') || isEnabled('hideCoinsGlobally')) {
  104. createSelector("#PromotedGamesTable", "display:none");
  105. }
  106. if (isEnabled('hideMyGamesIcons')) {
  107. createSelector("#MyGamesTable td div img, #MyGamesTable td div a img", "display:none;");
  108. }
  109.  
  110. if (isEnabled('highlightNewForumPosts')) {
  111. hightlightNewClanForumPosts();
  112. }
  113. if (isEnabled('scrollGames')) {
  114. setupFixedWindowWithScrollableGames();
  115. }
  116. if (isEnabled('hideRightColumn')) {
  117. hideRightColumn();
  118. }
  119.  
  120. $("label[for='MultiDayRadio']").on("click", function () {
  121. registerGameTabClick()
  122.  
  123. });
  124. $("label[for='RealTimeRadio']").on("click", function () {
  125. registerGameTabClick()
  126. });
  127. $("label[for='BothRadio']").on("click", function () {
  128. registerGameTabClick()
  129. });
  130.  
  131. $(window).resize(function () {
  132. if (isEnabled('scrollGames')) {
  133. refreshSingleColumnSize();
  134. }
  135. });
  136. }
  137.  
  138. if (pageIsClanThread()) {
  139. registerClanThread();
  140. }
  141.  
  142.  
  143. /**
  144. * Globally Hide Coins
  145. */
  146. if (isEnabled('hideCoinsGlobally')) {
  147. $("#CoinsBtn").parent().next().css('left', 512);
  148. $("#CoinsBtn").parent().next().next().css('left', 635);
  149. $("#CoinsBtn").parent().next().next().next().css('left', 740);
  150. $("#LeaderboardTable").prev().remove();
  151. $("#LeaderboardTable").css({opacity:0, cursor:'default'});
  152. $("#LeaderboardTable a").css('display', 'none');
  153. $(".TopRightBar").find("a[href='/Coins/']").css('display', 'none');
  154. $(".dropdown-menu a[href='/Coins/']").parent().remove()
  155. $("a[href='/Win-Money']").css('display', 'none');
  156. $("#OpenTournamentsTable").css('display', 'none');
  157. }
  158.  
  159.  
  160.  
  161. /**
  162. * Reads the User-Settings from Localstorage
  163. */
  164. function readLocalstorage() {
  165.  
  166. //Settings
  167. $.each(userscriptSettings, function (key, setting) {
  168. setting.selected = localStorage.getItem(setting.id) == "true";
  169. });
  170. //Filters
  171. var filters = localStorage.getItem("openGamesFilters");
  172.  
  173. if (filters) {
  174. openGamesFilters = $.parseJSON(filters);
  175. } else {
  176. openGamesFilters = {};
  177. }
  178.  
  179. hideCoinSymbol = true;
  180. }
  181.  
  182. /**
  183. * Creates the Userscript-Menu
  184. */
  185. function setupUserscriptMenu() {
  186. var inputs = '';
  187. $.each(userscriptSettings, function (key, setting) {
  188. if (setting.title != '') {
  189. inputs += '<span class="title">' + setting.title + '</span><br>';
  190. }
  191. inputs += '<label for="' + setting.id + '">' + setting.text + '</label><input type="checkbox" id="' + setting.id + '"><br>';
  192. if (setting.addBreak) {
  193. inputs += '<hr>';
  194. }
  195. });
  196. inputs += '<div class="close-userscript">Close and Refresh</div>';
  197.  
  198. $("body").append("<div class='overlay' style='display: none'></div><div class='popup userscript-show' style='display: none'><div class='head'>Change Userscript Settings<img class='close-popup-img' src='https://i.imgur.com/RItbpDS.png' height='25' width='25'></div>" + inputs + "</div>");
  199. $(".userscript-show").on("change", function () {
  200. storeSettingsVariables();
  201. });
  202. $("#TopRightDropDown .dropdown-divider").before('<li><div class="userscript-menu">Userscript</div></li>');
  203.  
  204. $(".userscript-menu").on("click", function () {
  205. $(".userscript-show").fadeIn();
  206. $(".overlay").fadeIn();
  207. $("#TopRightDropDown").fadeOut();
  208. $("embed#main").attr('wmode', 'transparent');
  209. $("embed#main").css('opacity', '0');
  210. $("embed#main").attr('align', 'left');
  211. });
  212.  
  213. $(".close-userscript").on("click", function () {
  214. $(".userscript-show").fadeOut();
  215. $(".overlay").fadeOut();
  216. location.reload();
  217. });
  218.  
  219. $(".close-popup-img").on("click", function () {
  220. $(".userscript-show").fadeOut();
  221. $(".overlay").fadeOut();
  222. $("embed#main").css('opacity', '1');
  223. });
  224.  
  225. checkUserscriptMenuButtons();
  226.  
  227. }
  228.  
  229. function checkUserscriptMenuButtons() {
  230. $.each(userscriptSettings, function (key, setting) {
  231. $("#"+setting.id).prop("checked", setting.selected);
  232. });
  233. }
  234.  
  235. function StickyTitles(stickies) {
  236. var thisObj = this;
  237. thisObj.load = function () {
  238. stickies.each(function () {
  239. var thisSticky = $(this).wrap('<div class="followWrap" />');
  240. thisSticky.parent().height(thisSticky.outerHeight());
  241. var pos = parseInt(thisSticky.offset().top, 10) - parseInt($(".showSide").offset().top, 10);
  242. $.data(thisSticky[0], 'pos', pos);
  243. });
  244. $(".showSide").off("scroll.stickies").on("scroll.stickies", function () {
  245. thisObj.scroll();
  246. });
  247. };
  248.  
  249. thisObj.scroll = function () {
  250. stickies.each(function (i) {
  251. var thisSticky = $(this),
  252. nextSticky = stickies.eq(i + 1),
  253. prevSticky = stickies.eq(i - 1),
  254. pos = $.data(thisSticky[0], 'pos');
  255. var showSide = $(".showSide");
  256. if (pos <= showSide.scrollTop()) {
  257. thisSticky.addClass("fixed");
  258. if (nextSticky.length > 0 && thisSticky.offset().top >= $.data(nextSticky[0], 'pos') - thisSticky.outerHeight()) {
  259. thisSticky.addClass("absolute").css("top", jQuery.data(nextSticky[0], 'pos') - thisSticky.outerHeight());
  260. }
  261. } else {
  262. thisSticky.removeClass("fixed");
  263. if (prevSticky.length > 0 && showSide.scrollTop() <= $.data(thisSticky[0], 'pos') - prevSticky.outerHeight()) {
  264. prevSticky.removeClass("absolute").removeAttr("style");
  265. }
  266. }
  267. });
  268. }
  269. }
  270.  
  271. jQuery.fn.outerHTML = function (s) {
  272. return s ? this.before(s).remove() : jQuery("<p>").append(this.eq(0).clone()).html();
  273. };
  274.  
  275.  
  276. /**
  277. * Triggers a click on the expand Games Button
  278. */
  279. function triggerExpandGames() {
  280. if (showAllGames == "" || showAllGames.length == 0) {
  281. showAllGames = $("#ShowMoreOpenGamesLink");
  282. showAllGames.trigger("click");
  283. }
  284. if (showAllCoinGames == "") {
  285. showAllCoinGames = $("#ShowMorePromotedGamesLink");
  286. showAllCoinGames.trigger("click");
  287. }
  288.  
  289. }
  290.  
  291. function markJoinedGames() {
  292. var gamesSwitch = setInterval(function (){
  293. applyOpenGameFilters();
  294. updateOpenGamesCounter();
  295. var name = $(".TopRightBar a:nth-of-type(2)").text();
  296. var playerLabel = '<span style="font-size:12px; color:gray"> You already joined</span>'
  297. $.each($("#OpenGamesTable tr"), function (key, tableRow) {
  298. $.each($(tableRow).find("span span"), function (key2, player) {
  299. if ($(player).attr("title") == name && $(tableRow).html().indexOf("You already joined") < 0) {
  300. $(tableRow).find("td:nth-of-type(2) a").append(playerLabel)
  301. }
  302. });
  303.  
  304. })
  305. }, 5);
  306. setTimeout(function () {
  307. clearInterval(gamesSwitch);
  308. }, 400)
  309. }
  310.  
  311. /**
  312. * Delayed function for expanding Games
  313. */
  314. function expandGames() {
  315. numOfGames = 0;
  316. delayedFunction = setInterval(triggerExpandGames, 100);
  317. setTimeout(function () {
  318. clearInterval(delayedFunction);
  319. }, 3000);
  320. }
  321.  
  322. /**
  323. * Stores User-Settings to local Storage
  324. */
  325. function storeSettingsVariables() {
  326. $.each(userscriptSettings, function (key, setting) {
  327. localStorage.setItem(setting.id, $("#"+setting.id).prop("checked"));
  328. });
  329. }
  330.  
  331. /**
  332. * Refreshes Width & Height of Columns
  333. */
  334. function refreshSingleColumnSize() {
  335. var showSide = $(".showSide");
  336. var showGames = $(".showGames");
  337. showSide.scrollTop(0);
  338. /**
  339. * Sticky Titles
  340. */
  341. $(".followMeBar").each(function () {
  342. $(this).removeClass("fixed");
  343. if ($(this).parent().hasClass("followWrap")) {
  344. $(this).unwrap();
  345. }
  346. var thisSticky = $(this).wrap('<div class="followWrap" />');
  347. thisSticky.parent().height(thisSticky.outerHeight());
  348.  
  349. var pos = parseInt(thisSticky.offset().top) - parseInt(showSide.offset().top);
  350. $.data(thisSticky[0], 'pos', pos);
  351. });
  352. var width = $("#ForumTable").width();
  353. createSelector(".followMeBar", "width:" + width + "px;");
  354.  
  355. showGames.find("table").css({
  356. height: window.innerHeight - 150
  357. });
  358. //var height = showGames.find("table thead tr").height() + 30;
  359. var height = 48;
  360. createSelector(".showGames table tbody tr:first-of-type td", "padding-top:" + height + "px");
  361.  
  362.  
  363. showSide.css({
  364. height: window.innerHeight - 150
  365. });
  366. showGames.find("table tbody tr:first-of-type td").css("padding-top", height)
  367.  
  368. /************************/
  369. $(".showGames thead tr td div").unwrap();
  370. /**************************/
  371. }
  372.  
  373. /**
  374. * Create a CSS selector
  375. * @param name The name of the object, which the rules are applied to
  376. * @param rules The CSS rules
  377. */
  378. function createSelector(name, rules) {
  379. var style = document.createElement('style');
  380. style.type = 'text/css';
  381. document.getElementsByTagName('head')[0].appendChild(style);
  382. if (!(style.sheet || {}).insertRule) {
  383. (style.styleSheet || style.sheet).addRule(name, rules);
  384. } else {
  385. style.sheet.insertRule(name + "{" + rules + "}", 0);
  386. }
  387. }
  388.  
  389. /**
  390. * Reloads all Games
  391. */
  392.  
  393. function refreshAllGames(force) {
  394. if ($(".popup").is(":visible") && !force) {
  395. return;
  396. }
  397. $('table').css('overflow-y','hidden')
  398. myGamesTable.find("tbody").fadeTo('slow', 0.15);
  399. openGamesTable.find("tbody").fadeTo('slow', 0.15);
  400. promotedGamesTable.find("tbody").fadeTo('slow', 0.15);
  401.  
  402. var page = $('<div />').load('https://www.warlight.net/MultiPlayer/ ', function () {
  403. var myGames = page.find('#MyGamesTable tbody tr');
  404. //var openGames = page.find('#OpenGamesTable tbody tr');
  405. var promotedGames = page.find('#PromotedGamesTable tbody tr');
  406. showAllGames = page.find("#ShowMoreOpenGamesLink");
  407.  
  408. promotedGamesTable.find("tbody tr").remove();
  409.  
  410. $.each(myGamesTable.find("tbody tr"), function (key, value) {
  411. if ($(value).html().indexOf("PastGames") == -1) {
  412. $(value).remove();
  413. }
  414. });
  415.  
  416. myGamesTable.find("tbody").prepend(myGames);
  417. //$("#OpenGamesTable").find("tbody").prepend(openGames);
  418. promotedGamesTable.find("tbody").prepend(promotedGames);
  419. $("#MorePromotedGamesHorizontalRow").remove();
  420.  
  421. $("#ShowMorePromotedGamesLinkContainer").remove();
  422.  
  423. $.each($(".TournamentRow td"), function () {
  424. $(this).find("font:first-of-type").appendTo($(this).find("a")).css("font-size", "10px");
  425. });
  426.  
  427.  
  428. myGamesTable.find("tbody").fadeTo('slow', 1);
  429. myGamesTable.css('overflow-y','scroll');
  430. //openGamesTable.find("tbody").fadeTo('slow', 1);
  431. promotedGamesTable.find("tbody").fadeTo('slow', 1);
  432. promotedGamesTable.css('overflow-y','scroll');
  433. markJoinedGames();
  434.  
  435. if (isEnabled('scrollGames')) {
  436. refreshSingleColumnSize();
  437. openGamesTable.scrollTop(0);
  438. myGamesTable.scrollTop(0);
  439. promotedGamesTable.scrollTop(0);
  440. }
  441.  
  442. });
  443.  
  444. var activeTabLoad;
  445. var activeTabClass;
  446. openGames = [];
  447. var active = $("#OpenGamesTable .ui-buttonset .ui-state-active").text();
  448.  
  449. if (active.indexOf('Both') > -1) {
  450. activeTabLoad = ["BothRadio", "RealTimeRadio", "MultiDayRadio"];
  451. activeTabClass = ["bothOpenGames", "realOpenGames", "multiOpenGames"];
  452. } else if (active.indexOf('Real') > -1) {
  453. activeTabLoad = ["RealTimeRadio", "MultiDayRadio", "BothRadio"];
  454. activeTabClass = ["realOpenGames", "multiOpenGames", "bothOpenGames"];
  455. } else {
  456. activeTabLoad = ["MultiDayRadio", "RealTimeRadio", "BothRadio"];
  457. activeTabClass = ["multiOpenGames", "realOpenGames", "bothOpenGames"];
  458. }
  459. $("#iframeiii").remove();
  460. //Reload open games
  461. var ifr = $('<iframe/>', {
  462. id: 'iframeiii',
  463. src: 'https://www.warlight.net/MultiPlayer/OpenGames',
  464. style: 'position:fixed;z-index: 100000;right: 0;top:0;width:1px;height:1px;opacity:0',
  465. load: function () {
  466. setTimeout(function () {
  467. $("#iframeiii").contents().find("label[for='" + activeTabLoad[2] + "']").trigger('click');
  468. setTimeout(function () {
  469. openGames.push($("#iframeiii").contents().find('#OpenGamesTable tbody tr').addClass(activeTabClass[2]));
  470. $("#iframeiii").contents().find("label[for='" + activeTabLoad[1] + "']").trigger('click');
  471. setTimeout(function () {
  472. openGames.push($("#iframeiii").contents().find('#OpenGamesTable tbody tr').addClass(activeTabClass[1]));
  473. $("#iframeiii").contents().find("label[for='" + activeTabLoad[0] + "']").trigger('click');
  474. setTimeout(function () {
  475.  
  476. var openGamesMenu = '<div id="fakeOpenGameMenu" style="float: right" class="ui-buttonset"> <input type="radio" id="MultiDayRadio" name="pace" checked="checked" class="ui-helper-hidden-accessible"><label for="MultiDayRadio" class="ui-state-active ui-button ui-widget ui-state-default ui-button-text-only ui-corner-left" role="button"><span class="ui-button-text">' + $("#iframeiii").contents().find("label[for='MultiDayRadio']").text() + '</span></label><input type="radio" id="RealTimeRadio" name="pace" class="ui-helper-hidden-accessible"><label for="RealTimeRadio" class="ui-button ui-widget ui-state-default ui-button-text-only" role="button"><span class="ui-button-text">' + $("#iframeiii").contents().find("label[for='RealTimeRadio']").text() + '</span></label><input type="radio" id="BothRadio" name="pace" class="ui-helper-hidden-accessible"><label for="BothRadio" class="ui-button ui-widget ui-state-default ui-button-text-only ui-corner-right" role="button"><span class="ui-button-text">' + $("#iframeiii").contents().find("label[for='BothRadio']").text() + '</span></label></div>';
  477.  
  478. openGames.push($("#iframeiii").contents().find('#OpenGamesTable tbody tr').addClass(activeTabClass[0]));
  479. $("#OpenGamesTable thead tr td .ui-buttonset").remove();
  480. $("#OpenGamesTable thead tr td").append(openGamesMenu);
  481. $("#OpenGamesTable tbody tr").remove();
  482.  
  483.  
  484. $("#OpenGamesTable tbody").append(openGames[0]);
  485. $("#OpenGamesTable tbody").append(openGames[1]);
  486. $("#OpenGamesTable tbody").append(openGames[2]);
  487. $("RestoreLotteryGamesBtn").remove();
  488.  
  489. $("label[for='MultiDayRadio']").on("click", function () {
  490. $(".hidden").removeClass("hidden");
  491. openGamesTable.scrollTop(0);
  492. $(".multiOpenGames").show();
  493. $(".multiOpenGames").prependTo("#OpenGamesTable tbody");
  494. $(".realOpenGames").addClass('hidden').hide();
  495. $(".bothOpenGames").addClass('hidden').hide();
  496. openGamesTable.scrollTop(0);
  497. $(this).addClass('ui-state-active');
  498. $("label[for='BothRadio']").removeClass('ui-state-active');
  499. $("label[for='RealTimeRadio']").removeClass('ui-state-active');
  500. $("#iframeiii").contents().find("label[for='MultiDayRadio']").trigger('click');
  501. markJoinedGames();
  502.  
  503. });
  504. $("label[for='RealTimeRadio']").on("click", function () {
  505. $(".hidden").removeClass("hidden");
  506. openGamesTable.scrollTop(0);
  507. $(".multiOpenGames").addClass('hidden').hide();
  508. $(".realOpenGames").show();
  509. $(".realOpenGames").prependTo("#OpenGamesTable tbody");
  510. $(".bothOpenGames").addClass('hidden').hide();
  511. $(this).addClass('ui-state-active');
  512. $("label[for='MultiDayRadio']").removeClass('ui-state-active');
  513. $("label[for='BothRadio']").removeClass('ui-state-active');
  514. $("#iframeiii").contents().find("label[for='RealTimeRadio']").trigger('click');
  515. markJoinedGames();
  516. });
  517. $("label[for='BothRadio']").on("click", function () {
  518. $(".hidden").removeClass("hidden");
  519. openGamesTable.scrollTop(0);
  520. $(".multiOpenGames").addClass('hidden').hide();
  521. $(".realOpenGames").addClass('hidden').hide();
  522. $(".bothOpenGames").show();
  523. $(".bothOpenGames").prependTo("#OpenGamesTable tbody");
  524. $(this).addClass('ui-state-active');
  525. $("label[for='MultiDayRadio']").removeClass('ui-state-active');
  526. $("label[for='RealTimeRadio']").removeClass('ui-state-active');
  527. $("#iframeiii").contents().find("label[for='BothRadio']").trigger('click');
  528. markJoinedGames();
  529.  
  530. });
  531.  
  532. $($(".realOpenGames")[0]).find("td").css("padding-top", 48);
  533. $($(".bothOpenGames")[0]).find("td").css("padding-top", 48)
  534. var activeT = "label[for='" + activeTabLoad[0] + "']";
  535. $("#OpenGamesTable").hide();
  536. $(activeT).trigger('click');
  537. $("#OpenGamesTable").show();
  538. openGamesTable.find("tbody").fadeTo('slow', 1);
  539. openGamesTable.css('overflow-y','scroll');
  540. markJoinedGames();
  541.  
  542. }, 100);
  543. }, 100);
  544. }, 100);
  545. }, 100);
  546.  
  547. }
  548. });
  549. $('body').append(ifr);
  550. }
  551.  
  552. /**
  553. * Setups the refresh functionality
  554. */
  555. function setupRefreshFunction() {
  556. lastRefresh = new Date();
  557. var oldRefreshBtn = $("#RefreshBtn");
  558. var oldRefreshBtn2 = $("#RefreshBtn2");
  559. if (oldRefreshBtn.length) {
  560. var newRefreshBtn = $("#refreshAll");
  561. oldRefreshBtn.replaceWith(oldRefreshBtn.clone().removeAttr("id").attr("id", "refreshAll").attr("value", "Refresh (R)"));
  562. newRefreshBtn.appendTo("body");
  563. $("#refreshAll").on("click", function () {
  564. if (new Date() - lastRefresh > 3000) {
  565. lastRefresh = new Date();
  566. refreshAllGames();
  567. }
  568. });
  569. } else if (oldRefreshBtn2.length) {
  570. var newRefreshBtn = $("#refreshAll");
  571. oldRefreshBtn2.replaceWith(oldRefreshBtn2.clone().removeAttr("id").attr("id", "refreshAll").attr("value", "Refresh (R)"));
  572. newRefreshBtn.appendTo("body");
  573. $("#refreshAll").on("click", function () {
  574. if (new Date() - lastRefresh > 3000) {
  575. lastRefresh = new Date();
  576. refreshAllGames();
  577. }
  578. });
  579. }
  580. $(".SideColumn").after($("#refreshAll"))
  581.  
  582. if (isEnabled('autoRefreshOnFocus')) {
  583. $(window).on('focus', function () {
  584. if (new Date() - lastRefresh > 30000) {
  585. lastRefresh = new Date();
  586. refreshAllGames();
  587. }
  588. });
  589. }
  590.  
  591. $("body").keyup(function (event) {
  592. // "R" is pressed
  593. if (event.which == 82) {
  594. if (new Date() - lastRefresh > 3000) {
  595. lastRefresh = new Date();
  596. refreshAllGames();
  597. }
  598. }
  599. });
  600.  
  601. openGamesTable.prepend("<div class='loading loading-open'><img src='https://www.adobe.com/business/calculator/VIP/image/loader.gif' height='32' width='32'></div>");
  602. myGamesTable.prepend("<div class='loading loading-my'><img src='https://www.adobe.com/business/calculator/VIP/image/loader.gif' height='32' width='32'></div>");
  603. promotedGamesTable.prepend("<div class='loading loading-prom'><img src='https://www.adobe.com/business/calculator/VIP/image/loader.gif' height='32' width='32'></div>");
  604. }
  605.  
  606.  
  607. function getDate(text) {
  608. var date;
  609.  
  610. if (text.match(/[0-9]+ second/)) {
  611. date = new Date() - 1000;
  612.  
  613. } else if (text.match(/[0-9]+ seconds/)) {
  614. date = new Date() - text.match(/[0-9]+/) * 1000;
  615.  
  616. } else if (text.match(/[0-9]+ minute/)) {
  617. date = new Date() - text.match(/[0-9]+/) * 1000 * 60;
  618.  
  619. } else if (text.match(/[0-9]+ minutes/)) {
  620. date = new Date() - text.match(/[0-9]+/) * 1000 * 60;
  621.  
  622. } else if (text.match(/[0-9]+ hour/)) {
  623. date = new Date() - text.match(/[0-9]+/) * 1000 * 60 * 59;
  624.  
  625. } else if (text.match(/[0-9]+ hours/)) {
  626. date = new Date() - text.match(/[0-9]+/) * 1000 * 60 * 60;
  627.  
  628. } else if (text.match(/[0-9]+ day/)) {
  629. date = new Date() - text.match(/[0-9]+/) * 1000 * 60 * 60 * 36;
  630.  
  631. } else if (text.match(/[0-9]+ days/)) {
  632. date = new Date() - text.match(/[0-9]+/) * 1000 * 60 * 60 * 24;
  633.  
  634. } else if (text.match(/[0-9]+[\/][0-9]+[\/][0-9]+/)) {
  635. var split = text.split('/');
  636. date = new Date(split[2], split[0]-1, split[1]);
  637. date.setHours(0, 0, 0, 0);
  638. }
  639. return date;
  640. }
  641.  
  642.  
  643. var searches = 0;
  644. function filterMailTo() {
  645. if (searches == 0) {
  646. $($("#MainSiteContent div:nth-of-type(1)")[0]).children().remove()
  647. searches++;
  648. }
  649. var find = $("#search_input").val().toLowerCase()
  650. if (find.length > 1) {
  651. removeUncheckedMail()
  652. $.each(data_mail, function (index, val) {
  653. if ($(val).text().toLowerCase().indexOf(find) > -1) {
  654. var id = $(val).attr("id").replace("Lbl_", "")
  655. if ($("#Lbl_"+id).length == 0) {
  656. $($("#MainSiteContent div:nth-of-type(1)")[0]).append('<input type="checkbox" id="CB_' + id + '" onclick="PlayerClicked(' + id + ')">').append(val).append("<br>")
  657. }
  658. }
  659. })
  660. }
  661. else {
  662. removeUncheckedMail()
  663. }
  664. }
  665.  
  666. function hideBlacklistedThreads() {
  667. var ids = JSON.parse(localStorage.getItem("blackListedThreads"));
  668. $.each($("#ForumTable tr"), function (key, row) {
  669. var href = $(row).html().match(/href="\/([^"]*)"/m);
  670. if (href) {
  671. href = "/" + href[1]
  672. if ($.inArray(href, ids) != -1) {
  673. $(row).remove()
  674. }
  675. }
  676. })
  677. }
  678.  
  679. function removeUncheckedMail() {
  680. $.each($($("#MainSiteContent div:nth-of-type(1)")[0]).find("label"), function (index, val) {
  681. var id = $(val).attr("id").replace("Lbl_", "")
  682. if ( ! $('#CB_'+id).is(":checked")) {
  683. $(val).next().remove()
  684. $(val).prev().remove()
  685. $(val).remove()
  686. }
  687. })
  688. }
  689. var data_mail = []
  690. if (location.href.match(/.*warlight[.]net\/Discussion\/SendMail$/)) {
  691. $($("#MainSiteContent div:nth-of-type(1)")[0]).before('<input id="search_input" placeholder="Filter" style="margin-bottom:10px">')
  692. $("#search_input").on("input", function () {
  693. filterMailTo()
  694. })
  695. $.each($($("#MainSiteContent div:nth-of-type(1)")[0]).find("label"), function (index, val) {
  696. data_mail.push($(val))
  697. });
  698.  
  699. }
  700.  
  701. if (!isEnabled('useDefaultBootLabel')) {
  702. createSelector(".BootTimeLabel", "color:white !important;font-weight:normal!important;font-style:italic;font-size:13px!important;z-index:50;");
  703. } else {
  704. createSelector(".BootTimeLabel", "z-index:50;");
  705. }
  706.  
  707. function setGlobalStyles() {
  708. var winHeight = $(window).height();
  709. createSelector(".userscript-menu", "display: block;color: #555;text-decoration: none;line-height: 18px;padding: 3px 15px;margin: 0;white-space: nowrap;");
  710. createSelector(".userscript-menu:hover", "cursor:pointer;background-color: #08C;color: #FFF;cursor: pointer;");
  711. createSelector(".popup", "position: fixed;width: 420px;left: 50%;background: #171717;margin-left: -242px;top: 100px;z-index: 50000001; color:white;padding:60px 30px 30px 30px;border: 2px solid gray;border-radius:8px;max-height:" + (winHeight - 200) + "px;overflow-y:auto");
  712. createSelector(".close-userscript", "margin-top: 40px;width: 100%;text-align: center;font-size: 15px;cursor: pointer;background: gray;line-height: 30px;border-radius: 8px;");
  713. createSelector(".close-popup-img", "float:right;margin:5px;cursor:pointer");
  714. createSelector(".popup label", "width: 80%;display: inline-block;font-size: 15px;margin: 5px;");
  715. createSelector(".popup .title", "color: gray;font-size: 15px;margin-top: 10px;display: inline-block;width: 95%;border-bottom: 1px gray solid;padding-bottom: 3px;");
  716. createSelector(".popup input[type='checkbox']", "width: 20px;height: 20px;margin-left:30px;margin: 5px;-moz-appearance:none;");
  717. createSelector(".overlay", "position: absolute;background: white;top: 0;left: 0;right: 0;bottom: 0;z-index: 50000000;opacity: 0.5;");
  718. createSelector(".popup .head", "position: fixed;height: 40px;background: #330000;width: 480px;left: 0;right: 0;top: 100px;color: white;font-size: 15px;text-align: center;line-height: 40px;border-top-left-radius:8px;border-top-right-radius:8px;margin:auto;z-index:10000;");
  719. createSelector(".userscript-show", "display:none");
  720. createSelector("#MorePromotedGamesHorizontalRow", "display:none");
  721. createSelector(".newSetting", "color: gold;font-weight: bold;");
  722. createSelector(".userscript-menu img", "height: 18px;display: inline-block;position: relative;margin-bottom: -5px;margin-right: 7px;");
  723. }
  724.  
  725. function hideFFAGames() {
  726. var hiddenGames = 0;
  727. $.each($("#OpenGamesTable tr"), function (key, tableRow) {
  728. if (rowIsFFAGame(tableRow) && $(tableRow).hasClass('GameRow')) {
  729. rowSlideUp(tableRow);
  730. hiddenGames++;
  731. }
  732. //var players = $(tableRow).find("td:nth-of-type(2) span span").length;
  733. //$(tableRow).find("td:nth-of-type(2) a").append(" " + players )
  734. });
  735. return hiddenGames;
  736. }
  737.  
  738. function hideTeamGames() {
  739. var hiddenGames = 0;
  740. $.each($("#OpenGamesTable tr"), function (key, tableRow) {
  741. if (rowIsTeamGame(tableRow) && $(tableRow).hasClass('GameRow')) {
  742. rowSlideUp(tableRow);
  743. hiddenGames++;
  744. }
  745. //var players = $(tableRow).find("td:nth-of-type(2) span span").length;
  746. //$(tableRow).find("td:nth-of-type(2) a").append(" " + players )
  747. });
  748. return hiddenGames;
  749. }
  750.  
  751. function hideGamesWithLuckOver(maxLuck) {
  752. var hiddenGames = 0;
  753. if (maxLuck < 100) {
  754. $.each($("#OpenGamesTable tr"), function (key, tableRow) {
  755. var luck = getLuckFromRow(tableRow);
  756. if (parseInt(luck) > maxLuck) {
  757. rowSlideUp(tableRow);
  758. hiddenGames++;
  759. }
  760. });
  761. }
  762. return hiddenGames;
  763. }
  764.  
  765. function hide1v1Games() {
  766. var hiddenGames = 0;
  767. $.each($("#OpenGamesTable tr"), function (key, tableRow) {
  768. if (rowIs1v1Game(tableRow) && $(tableRow).hasClass('GameRow')) {
  769. rowSlideUp(tableRow);
  770. hiddenGames++;
  771. }
  772. });
  773. return hiddenGames;
  774. }
  775.  
  776. function hideCustomScenarioGames() {
  777. var hiddenGames = 0;
  778. $.each($("#OpenGamesTable tr"), function (key, tableRow) {
  779. if (rowIsCustomScenarioGame(tableRow) && $(tableRow).hasClass('GameRow')) {
  780. rowSlideUp(tableRow);
  781. hiddenGames++;
  782. }
  783. });
  784. return hiddenGames;
  785. }
  786.  
  787. function hidePracticeGames() {
  788. var hiddenGames = 0;
  789. $.each($("#OpenGamesTable tr"), function (key, tableRow) {
  790. if (rowIsPracticeGame(tableRow) && $(tableRow).hasClass('GameRow')) {
  791. rowSlideUp(tableRow);
  792. hiddenGames++;
  793. }
  794. });
  795. return hiddenGames;
  796. }
  797.  
  798. function hideManualDistributionGames() {
  799. var hiddenGames = 0;
  800. $.each($("#OpenGamesTable tr"), function (key, tableRow) {
  801. if (rowIsManualDistributionGame(tableRow) && $(tableRow).hasClass('GameRow')) {
  802. rowSlideUp(tableRow);
  803. hiddenGames++;
  804. }
  805. });
  806. return hiddenGames;
  807. }
  808.  
  809. function hideAutoDistributionGames() {
  810. var hiddenGames = 0;
  811. $.each($("#OpenGamesTable tr"), function (key, tableRow) {
  812. if (rowIsAutoDistributionGame(tableRow) && $(tableRow).hasClass('GameRow')) {
  813. rowSlideUp(tableRow);
  814. hiddenGames++;
  815. }
  816. });
  817. return hiddenGames;
  818. }
  819. function hideKeywordGames() {
  820. var keywords = openGamesFilters["hideKeyword"].split(",");
  821. var hiddenGames = 0;
  822. $.each($("#OpenGamesTable tr"), function (key, tableRow) {
  823. var title = $(tableRow).find("td > a").text().toLowerCase();
  824. $.each(keywords, function (key, keyword) {
  825. if (title.indexOf(keyword.trim().toLowerCase()) != -1 && keyword.trim().length > 1 && $(tableRow).hasClass('GameRow')) {
  826. rowSlideUp(tableRow);
  827. hiddenGames++;
  828. }
  829. })
  830. });
  831. return hiddenGames;
  832. }
  833.  
  834. function hideRealTimeBootGames() {
  835. var bootMin = openGamesFilters["hideRealTimeBootTime"] || 0;
  836. var hiddenGames = 0;
  837. $.each($("#OpenGamesTable tr"), function (key, tableRow) {
  838. if (getBootMin(tableRow) < 240 && getBootMin(tableRow) < bootMin && $(tableRow).hasClass('GameRow')) {
  839. rowSlideUp(tableRow);
  840. hiddenGames++;
  841. }
  842. });
  843. return hiddenGames;
  844. }
  845.  
  846. function hideMultiDayBootGames() {
  847. var bootMin = parseFloat(openGamesFilters["hideMultiDayBootTimeDays"] || 0) * 24 * 60 + parseFloat(openGamesFilters["hideMultiDayBootTimeHours"] || 0) * 60;
  848. var hiddenGames = 0;
  849. $.each($("#OpenGamesTable tr"), function (key, tableRow) {
  850. if (getBootMin(tableRow) >= 240 && getBootMin(tableRow) < bootMin && $(tableRow).hasClass('GameRow')) {
  851. rowSlideUp(tableRow);
  852. hiddenGames++;
  853. }
  854. });
  855. return hiddenGames;
  856. }
  857.  
  858. function getBootMin(row) {
  859. var bootTimeLabel = $(row).find(".BootTimeLabel").text();
  860. var min = bootTimeLabel.match(/(?:[0-9]* hour[s]? |)([0-9]*) minutes?/) || 0;
  861. var hours = bootTimeLabel.match(/(?:([0-9]*) hour[s]? |)[0-9]* minutes?/) || bootTimeLabel.match(/(?:[0-9]* day[s]? |)([0-9]*) hours?/) || 0;
  862. var days = bootTimeLabel.match(/([0-9]*) day[s]?(?: [0-9]* hours?|)/) || 0;
  863. var totalMin = parseFloat(min[1] || 0) + parseFloat(hours[1] || 0) * 60 + parseFloat(days[1] || 0) * 24 * 60;
  864. return totalMin;
  865. }
  866.  
  867. function rowIsFFAGame(row) {
  868. return $(row).find("[src='https://d2wcw7vp66n8b3.cloudfront.net/Images/GameInfoIcons/Teams.png']").length == 0 && $(row).find("td:nth-of-type(2) span span").length > 2;
  869. }
  870.  
  871. function rowIs1v1Game(row) {
  872. return $(row).find("td:nth-of-type(2) span span").length == 2;
  873. }
  874.  
  875. function rowIsTeamGame(row) {
  876. return $(row).find("[src='https://d2wcw7vp66n8b3.cloudfront.net/Images/GameInfoIcons/Teams.png']").length == 1 && $(row).find("td:nth-of-type(2) span span").length > 2;
  877. }
  878.  
  879. function rowIsCustomScenarioGame(row) {
  880. return $(row).find("[src='https://d2wcw7vp66n8b3.cloudfront.net/Images/GameInfoIcons/CustomScenario.png']").length == 1;
  881. }
  882.  
  883. function rowIsPracticeGame(row) {
  884. return $(row).find("[src='https://d2wcw7vp66n8b3.cloudfront.net/Images/GameInfoIcons/PracticeGame.png']").length == 1;
  885. }
  886.  
  887. function rowIsManualDistributionGame(row) {
  888. return $(row).find("[src='https://d2wcw7vp66n8b3.cloudfront.net/Images/GameInfoIcons/ManualDistribution.png']").length == 1;
  889. }
  890.  
  891. function rowIsAutoDistributionGame(row) {
  892. return $(row).find("[src='https://d2wcw7vp66n8b3.cloudfront.net/Images/GameInfoIcons/AutoDist.png']").length == 1;
  893. }
  894.  
  895. function getLuckFromRow(row) {
  896. var luck = 0;
  897. if ($(row).find("[src='https://d2wcw7vp66n8b3.cloudfront.net/Images/GameInfoIcons/LuckModifier.png']").length == 1) {
  898. luck = $(row).find("[src='https://d2wcw7vp66n8b3.cloudfront.net/Images/GameInfoIcons/LuckModifier.png']").attr('title').match(/^[^1-9]*(.*)%/)[1]
  899. }
  900. return luck;
  901. }
  902.  
  903. window.applyOpenGameFilters = function () {
  904. var hiddenGames = 0;
  905. if (showOpenGamesFilter && openGamesFilters["disableAll"] != true) {
  906. if (openGamesFilters["hideLuck"] < 100) {
  907. hiddenGames += hideGamesWithLuckOver(openGamesFilters["hideLuck"])
  908. }
  909. if (openGamesFilters["hideFFA"]) {
  910. hiddenGames += hideFFAGames();
  911. }
  912.  
  913. if (openGamesFilters["hideTeam"]) {
  914. hiddenGames += hideTeamGames();
  915. }
  916.  
  917. if (openGamesFilters["hide1v1"]) {
  918. hiddenGames += hide1v1Games();
  919. }
  920. if (openGamesFilters["hideCustomScenario"]) {
  921. hiddenGames += hideCustomScenarioGames();
  922. }
  923. if (openGamesFilters["hidePractice"]) {
  924. hiddenGames += hidePracticeGames();
  925. }
  926. if (openGamesFilters["hideManualDistribution"]) {
  927. hiddenGames += hideManualDistributionGames();
  928. }
  929. if (openGamesFilters["hideAutoDistribution"]) {
  930. hiddenGames += hideAutoDistributionGames();
  931. }
  932. if (openGamesFilters["hideKeyword"] && openGamesFilters["hideKeyword"].trim() != "") {
  933. hiddenGames += hideKeywordGames();
  934. }
  935. if (openGamesFilters["hideRealTimeBootTime"] > 0) {
  936. hiddenGames += hideRealTimeBootGames();
  937. }
  938. if (openGamesFilters["hideMultiDayBootTimeDays"] > 0 || openGamesFilters["hideMultiDayBootTimeHours"] > 0) {
  939. hiddenGames += hideMultiDayBootGames();
  940. }
  941. }
  942. if (hiddenGames > 0 && $("#gamesAreHidden").length == 0) {
  943. $("#RestoreLotteryGamesBtn").after("<span id='gamesAreHidden' style='color: gray;font-style: italic;'>Some Games are hidden</span>");
  944. $("#gamesAreHidden").parent().parent().removeClass()
  945. }
  946. }
  947.  
  948.  
  949. function rowSlideUp(row) {
  950. $(row).remove();
  951. //$(row).css("background", "red")
  952. }
  953.  
  954. function storeFilterVariables() {
  955. openGamesFilters = {};
  956. openGamesFilters["disableAll"] = $("#disableAll").prop("checked")
  957. openGamesFilters["hideTeam"] = $("#hideTeam").prop("checked")
  958. openGamesFilters["hideFFA"] = $("#hideFFA").prop("checked")
  959. openGamesFilters["hide1v1"] = $("#hide1v1").prop("checked")
  960. openGamesFilters["hideManualDistribution"] = $("#hideManualDistribution").prop("checked")
  961. openGamesFilters["hideAutoDistribution"] = $("#hideAutoDistribution").prop("checked")
  962. openGamesFilters["hideCustomScenario"] = $("#hideCustomScenario").prop("checked")
  963. openGamesFilters["hidePractice"] = $("#hidePractice").prop("checked")
  964. openGamesFilters["hideKeyword"] = $("#hideKeyword").val()
  965. openGamesFilters["hideRealTimeBootTime"] = $("#hideRealTimeBootTime").val()
  966. openGamesFilters["hideMultiDayBootTimeDays"] = $("#hideMultiDayBootTimeDays").val()
  967. openGamesFilters["hideMultiDayBootTimeHours"] = $("#hideMultiDayBootTimeHours").val()
  968.  
  969. var luck = $("#hideLuck").val();
  970. if ($.isNumeric(luck) && luck <= 100 && luck >= 0) {
  971. openGamesFilters["hideLuck"] = luck;
  972. } else {
  973. openGamesFilters["hideLuck"] = 0;
  974. }
  975. var rtBoot = $("#hideRealTimeBootTime").val();
  976. if ($.isNumeric(rtBoot)) {
  977. openGamesFilters["hideRealTimeBootTime"] = rtBoot;
  978. } else {
  979. openGamesFilters["hideRealTimeBootTime"] = 0;
  980. }
  981. var mdBootDay = $("#hideMultiDayBootTimeDays").val();
  982. if ($.isNumeric(mdBootDay)) {
  983. openGamesFilters["hideMultiDayBootTimeDays"] = mdBootDay;
  984. } else {
  985. openGamesFilters["hideMultiDayBootTimeDays"] = 0;
  986. }
  987. var mdBootHour = $("#hideMultiDayBootTimeHours").val();
  988. if ($.isNumeric(mdBootHour)) {
  989. openGamesFilters["hideMultiDayBootTimeHours"] = mdBootHour;
  990. } else {
  991. openGamesFilters["hideMultiDayBootTimeHours"] = 0;
  992. }
  993. localStorage.setItem("openGamesFilters", JSON.stringify(openGamesFilters));
  994. updateFilterSettings()
  995. }
  996.  
  997. function updateFilterSettings() {
  998. $("#disableAll").prop("checked", openGamesFilters["disableAll"]);
  999. $("#hideTeam").prop("checked", openGamesFilters["hideTeam"]);
  1000. $("#hideFFA").prop("checked", openGamesFilters["hideFFA"]);
  1001. $("#hide1v1").prop("checked", openGamesFilters["hide1v1"]);
  1002. $("#hideManualDistribution").prop("checked", openGamesFilters["hideManualDistribution"]);
  1003. $("#hideAutoDistribution").prop("checked", openGamesFilters["hideAutoDistribution"]);
  1004. $("#hideCustomScenario").prop("checked", openGamesFilters["hideCustomScenario"]);
  1005. $("#hidePractice").prop("checked", openGamesFilters["hidePractice"]);
  1006. $("#hideLuck").val(openGamesFilters["hideLuck"] || 100);
  1007. $("#hideKeyword").val(openGamesFilters["hideKeyword"] || "");
  1008. $("#hideRealTimeBootTime").val(openGamesFilters["hideRealTimeBootTime"] || 0);
  1009. $("#hideMultiDayBootTimeDays").val(openGamesFilters["hideMultiDayBootTimeDays"] || 0);
  1010. $("#hideMultiDayBootTimeHours").val(openGamesFilters["hideMultiDayBootTimeHours"] || 0);
  1011. }
  1012.  
  1013. function isEnabled(setting) {
  1014. return $(userscriptSettings).settingIsEnabled(setting);
  1015. }
  1016.  
  1017. function pageIsMultiplayer() {
  1018. return location.href.match(/.*warlight[.]net\/MultiPlayer.*/);
  1019. }
  1020.  
  1021. function pageIsDashboard() {
  1022. return location.href.match(/.*warlight[.]net\/MultiPlayer\/#?$/);
  1023. }
  1024.  
  1025. function pageIsClanThread() {
  1026. return location.href.match(/.*warlight[.]net\/Discussion/);
  1027. }
  1028.  
  1029. function showOpenGamesLink() {
  1030. $("#SubTabRow td:nth-child(8)").after('<td valign="top"><img src="https://d2wcw7vp66n8b3.cloudfront.net/Images/Tabs/SubSelectedLeft.png" width="6" height="16" style="visibility: hidden"></td><td nowrap="nowrap" class="SubTabCell" id="openGamesTab"><a href="/MultiPlayer/OpenGames">Open Games</a></td><td valign="top"><img src="https://d2wcw7vp66n8b3.cloudfront.net/Images/Tabs/SubSelectedRight.png" width="6" height="16" style="visibility: hidden"></td><td width="10">&nbsp;</td>');
  1031. if (location.href.match(/.*warlight[.]net\/MultiPlayer\/OpenGames.*/)) {
  1032. $("#openGamesTab").addClass("SubTabCellSelected");
  1033. $("#openGamesTab").prev().children().css("visibility", "visible");
  1034. $("#openGamesTab").next().children().css("visibility", "visible");
  1035. }
  1036. }
  1037.  
  1038. function setupOpenGamesFilter() {
  1039. $("#OpenGamesTable thead tr td").prepend('<a id="editFilters" style="color:#DDDDDD;font-size: 14px;float: right;">▼</a>');
  1040. var filters_body = "<hr>";
  1041. filters_body += '<label for="disableAll">Disable All Filters</label><input type="checkbox" id="disableAll"><br>';
  1042. filters_body += "<hr>";
  1043. filters_body += '<label for="hideTeam">Hide Team Games</label><input type="checkbox" id="hideTeam"><br>';
  1044. filters_body += '<label for="hideFFA">Hide FFA Games</label><input type="checkbox" id="hideFFA"><br>';
  1045. filters_body += '<label for="hide1v1">Hide 1 v 1 Games</label><input type="checkbox" id="hide1v1"><hr>';
  1046. filters_body += '<label for="hideManualDistribution">Hide Manual Distribution Games</label><input type="checkbox" id="hideManualDistribution"><br>';
  1047. filters_body += '<label for="hideAutoDistribution">Hide Auto Distribution Games</label><input type="checkbox" id="hideAutoDistribution"><hr>';
  1048. filters_body += '<label for="hideCustomScenario">Hide Custom Scenario Games</label><input type="checkbox" id="hideCustomScenario"><br>';
  1049. filters_body += '<label for="hidePractice">Hide Practice Games</label><input type="checkbox" id="hidePractice"><hr>';
  1050. filters_body += '<label for="hideLuck" style="width:169px">Hide Luck greater than</label><input type="text" id="hideLuck" class="number"><hr>';
  1051. filters_body += '<label for="hideKeyword" style="width:115px">Hide Keywords</label><br><span class="info"><span class="info-preview">More information about Keyword Filtering...<br></span>Separate multiple Keywords (3+ letters) with a comma. <br>The Keyword Filter searches for matches in the complete Gametitle. (Case Insensitive)<br>Example: Keyword "Rop" removes the Game "Europe 3v3"</span><input type="text" id="hideKeyword" style="width: 95%;margin-left: 6px;"><hr>';
  1052. filters_body += '<label>Hide Boot Time lower than</label><br>';
  1053. filters_body += '<label for="hideRealTimeBootTime" style="width:100px">Realtime: </label><input class="number" type="text" id="hideRealTimeBootTime">minute(s)<br>';
  1054. filters_body += '<label for="hideMultiDayBootTimeDays" style="width:100px">Multiday: </label><input class="number" type="text" id="hideMultiDayBootTimeDays"> day(s) and <input class="number" type="text" id="hideMultiDayBootTimeHours"> hour(s)<hr>';
  1055. filters_body += '<div class="close-userscript">Close and Apply</div>';
  1056. $("body").append("<div class='popup filters-show' style='display: none'><div class='head'>Change Filter Settings<img class='close-popup-img' src='https://i.imgur.com/RItbpDS.png' height='25' width='25'></div>" + filters_body + "</div>");
  1057.  
  1058. 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');
  1059. createSelector('hr', 'height: 1px;border: none;background-color: gray;opacity:0.5;');
  1060. createSelector('.number', 'width: 31px');
  1061. 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;');
  1062. createSelector('.info:hover', 'max-height:500px');
  1063. createSelector('#hideKeyword', 'text-align: left;');
  1064.  
  1065. $("#hideLuck").after("%");
  1066.  
  1067. createSelector('.ui-button-text-only .ui-button-text', 'padding: .4em 0.6em;');
  1068. createSelector('#editFilters:hover', 'cursor:pointer');
  1069.  
  1070. $(".filters-show").on("change", function () {
  1071. storeFilterVariables();
  1072. });
  1073.  
  1074. $("#editFilters").on("click", function () {
  1075. $(".filters-show").fadeIn();
  1076. $(".overlay").fadeIn();
  1077. });
  1078.  
  1079. $(".close-userscript").on("click", function () {
  1080. $(".filters-show").fadeOut();
  1081. $(".overlay").fadeOut();
  1082. refreshAllGames(true);
  1083. });
  1084.  
  1085. $(".close-popup-img").on("click", function () {
  1086. $(".overlay").fadeOut();
  1087. $(".popup").fadeOut();
  1088. });
  1089.  
  1090. updateFilterSettings();
  1091. }
  1092.  
  1093. function hightlightNewClanForumPosts() {
  1094.  
  1095. var regex1 = /.* commented [\n \t]+/;
  1096. var regex2 = / ago/;
  1097. var regex3 = /.*\/Forum\//;
  1098. var regex4 = /-.*/;
  1099. var data = localStorage.getItem('clanForumThreadsTime');
  1100. if (data != null) {
  1101. data = JSON.parse(data);
  1102. } else if (data == null) {
  1103. data = [];
  1104. $.each($('#ClanForumTable tbody tr'), function (index, row) {
  1105. if ($(row).find('td a')[0].href.match(/.*Forum\/[0-9]+/)) {
  1106. var id = $(row).find('td a')[0].href.replace(regex3, "").replace(regex4, "");
  1107. data.push({id: id, date: new Date()});
  1108. }
  1109. });
  1110.  
  1111. localStorage.setItem('clanForumThreadsTime', JSON.stringify(data));
  1112. }
  1113.  
  1114. $.each($('#ClanForumTable tbody tr'), function (index, row) {
  1115. if ($(row).find('td a')[0].href.match(/.*Forum\/[0-9]+/)) {
  1116. var lastComment = $(row).find('td span').text().trim().replace(regex1, "").replace(regex2, "");
  1117. var id = $(row).find('td a')[0].href.replace(regex3, "").replace(regex4, "");
  1118. var found = false;
  1119.  
  1120. $.each(data, function (key, val) {
  1121. if (val.id == id) {
  1122. found = true;
  1123. if (getDate(lastComment) > new Date(val.date)) {
  1124. $(row).css('background', '#4C4C33');
  1125. }
  1126. }
  1127. });
  1128. if (!found) {
  1129. $(row).css('background', '#4C4C33');
  1130. }
  1131. }
  1132. });
  1133. }
  1134.  
  1135. function setupBasicDashboardStyles() {
  1136. createSelector(".GameRow a", "font-size:16px !important;");
  1137. createSelector('#PromotedGamesTable td:last-of-type a img', 'display:none');
  1138. createSelector("#MyGamesTable td > a > img", 'display:none');
  1139. 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;");
  1140. createSelector("#MyGamesTable td span a img, #MyGamesTable td span a img", "display:inherit;");
  1141. createSelector(".GameRow:hover", "background-color:rgb(50, 50, 50);cursor:pointer;");
  1142. createSelector(".GameRow a:hover", "text-decoration:none;");
  1143. createSelector(".TournamentRow a:hover", "text-decoration:none;");
  1144. createSelector(".TournamentRow:hover", "background-color:rgb(50, 50, 50);cursor:pointer;");
  1145. createSelector(".ui-buttonset label", "font-size:11px;");
  1146. createSelector("#OpenGamesTable label:hover", " border: 1px solid #59b4d4;background: #0078a3 50% 50% repeat-x;font-weight: bold;color: #ffffff;");
  1147. createSelector("#OpenGamesTable td:last-child,#MyGamesTable td:last-child, #PromotedGamesTable td:last-child", "position: relative;");
  1148. 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;");
  1149. 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;");
  1150. createSelector(".loading img", "position: absolute;top: 50%;left: 50%;margin-left: -16px;margin-top: -16px;");
  1151. createSelector("img", "position: relative;z-index:50;");
  1152. createSelector("input", "z-index: 1000;position: relative;");
  1153. createSelector(".showGames thead tr", "background: rgb(51, 0, 0) none repeat scroll 0% 0%;z-index: 5000000;position: absolute;padding: 5px;border-bottom: 1px solid rgb(68, 68, 68);border-top-left-radius: 8px;width: calc(100% - 30px);letter-spacing: 1px;");
  1154. createSelector(".showGames table tbody", "display:table;width:100%;");
  1155.  
  1156. $.each($(".TournamentRow td"), function () {
  1157. $(this).find("font:first-of-type").appendTo($(this).find("a")).css("font-size", "10px");
  1158. });
  1159. }
  1160.  
  1161. function setupFixedWindowStyles() {
  1162. 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");
  1163. var top = parseInt($(".showSide").offset().top) + parseInt(43);
  1164. createSelector(".followMeBar.fixed", "position: fixed;top: " + top + "px;z-index: 0;z-index:100;");
  1165. createSelector(".followMeBar.fixed.absolute", "position: absolute;");
  1166.  
  1167. createSelector(".showSide", "overflow-y:scroll;float: left;margin-top: 43px;padding-right: 6px;");
  1168. createSelector(".showSide thead", "display:none");
  1169. createSelector(".showSide table", "border-top-right-radius:0;border-top-left-radius:0");
  1170.  
  1171. createSelector("#switchGameRadio label", "margin-left: 6px !important");
  1172. createSelector(".showGames table", "display:block !important");
  1173. 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);");
  1174. createSelector("#MyGamesTable, #PromotedGamesTable, #OpenGamesTable", "display:none");
  1175. createSelector("#MainSiteContent > table > tbody > tr > td", "width:100%");
  1176. createSelector(".MainColumn", "min-width:535px");
  1177. createSelector(".MainColumn", "width:40.55% !important");
  1178. createSelector(".SideColumn", "float:left !important");
  1179. createSelector("h2 + span", "margin-right: 50px;");
  1180. createSelector("body", "overflow:hidden");
  1181. createSelector(".SideColumn", "width: 100% !important;");
  1182. createSelector("#MyGamesFilter", "width:200px");
  1183. createSelector(".showGames table", "display:block; overflow-y:scroll; overflow-x:hidden; border:1px gray solid; border-radius:8px");
  1184. createSelector(".adsbygoogle", "margin-top: 25px;");
  1185. 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");
  1186. createSelector("#refreshAll", "position: absolute;top: 20px;right: 31px");
  1187. createSelector("#fakeOpenGameMenu label", "margin-right:2px");
  1188. createSelector("#RestoreLotteryGamesBtn", "display:none");
  1189. }
  1190.  
  1191. function setupFixedTitlesInSideColumn() {
  1192. var blogTable = $("#BlogTable");
  1193. var realTimeLadderTable = $("#RealTimeLadderTable");
  1194. var forumTable = $("#ForumTable");
  1195. var clanForumTable = $("#ClanForumTable");
  1196. var mapOfTheWeekTable = $("#MapOfTheWeekTable");
  1197. var leaderboardTable = $("#LeaderboardTable");
  1198. var myTournamentsTable = $("#MyTournamentsTable");
  1199.  
  1200. blogTable.before("<div class='followMeBar'>" + blogTable.find("thead > tr > td").html() + "</div>");
  1201. realTimeLadderTable.before("<div class='followMeBar'>" + realTimeLadderTable.find("thead > tr > td").html() + "</div>");
  1202. forumTable.before("<div class='followMeBar'>" + forumTable.find("thead > tr > td").html() + "</div>");
  1203. clanForumTable.before("<div class='followMeBar'>" + clanForumTable.find("thead > tr > td").html() + "</div>");
  1204. mapOfTheWeekTable.before("<div class='followMeBar'>" + mapOfTheWeekTable.find("thead > tr > td").html() + "</div>");
  1205. leaderboardTable.before("<div class='followMeBar'>" + leaderboardTable.find("thead > tr > td").html() + "</div>");
  1206. myTournamentsTable.before("<div class='followMeBar'>" + myTournamentsTable.find("thead > tr > td").html() + "</div>");
  1207. new StickyTitles(jQuery(".followMeBar")).load();
  1208. }
  1209.  
  1210. function setupFixedWindowWithScrollableGames() {
  1211. var gameButtons = '<div style="margin: 10px;" id="switchGameRadio" class="ui-buttonset">';
  1212. gameButtons += '<input type="radio" id="ShowMyGames" name="switchGames" checked="checked" class="ui-helper-hidden-accessible">';
  1213. gameButtons += '<label for="ShowMyGames" class="ui-state-active ui-button ui-widget ui-state-default ui-button-text-only ui-corner-left" role="button"><span class="ui-button-text">My Games</span></label>';
  1214. if (isEnabled('hidePromotedGames') || isEnabled('hideCoinsGlobally')) {
  1215. gameButtons += '<input type="radio" id="ShowOpenGames" name="switchGames" class="ui-helper-hidden-accessible">';
  1216. gameButtons += '<label for="ShowOpenGames" class="ui-button ui-widget ui-state-default ui-button-text-only ui-corner-right" role="button"><span class="ui-button-text">Open Games</span></label>';
  1217. } else {
  1218. gameButtons += '<input type="radio" id="ShowOpenGames" name="switchGames" class="ui-helper-hidden-accessible">';
  1219. gameButtons += '<label for="ShowOpenGames" class="ui-button ui-widget ui-state-default ui-button-text-only" role="button"><span class="ui-button-text">Open Games</span></label>';
  1220. gameButtons += '<input type="radio" id="ShowCoinGames" name="switchGames" class="ui-helper-hidden-accessible">';
  1221. gameButtons += '<label for="ShowCoinGames" class="ui-button ui-widget ui-state-default ui-button-text-only ui-corner-right" role="button"><span class="ui-button-text">Coin Games</span></label>';
  1222. }
  1223.  
  1224. gameButtons += '</div>';
  1225.  
  1226.  
  1227. var mainColumn = $(".MainColumn ");
  1228. mainColumn.prepend('<div class="showGamesContainer">' + gameButtons + '<div class="showGames"></div></div>');
  1229. myGamesTable.appendTo(".showGames");
  1230.  
  1231. mainColumn.after('<div class="showSide"></div>');
  1232. $(".SideColumn").appendTo(".showSide");
  1233.  
  1234. setupFixedWindowStyles();
  1235. setupFixedTitlesInSideColumn();
  1236. refreshSingleColumnSize();
  1237.  
  1238. $("#switchGameRadio").find("label").on("click", function () {
  1239. var newShowGames = $(this).attr("for");
  1240. if (newShowGames != showGamesActive) {
  1241. $.each($("#switchGameRadio").find("label"), function () {
  1242. $(this).removeClass("ui-state-active");
  1243. });
  1244. $(this).addClass("ui-state-active");
  1245.  
  1246. if (newShowGames == "ShowMyGames") {
  1247. showGamesActive = newShowGames;
  1248. promotedGamesTable.appendTo("body");
  1249. openGamesTable.appendTo("body");
  1250. myGamesTable.appendTo(".showGames");
  1251. } else if (newShowGames == "ShowCoinGames") {
  1252. showGamesActive = newShowGames;
  1253. myGamesTable.appendTo("body");
  1254. openGamesTable.appendTo("body");
  1255. promotedGamesTable.appendTo(".showGames");
  1256. } else if (newShowGames == "ShowOpenGames") {
  1257. showGamesActive = newShowGames;
  1258. myGamesTable.appendTo("body");
  1259. promotedGamesTable.appendTo("body");
  1260. openGamesTable.appendTo(".showGames");
  1261. }
  1262.  
  1263. showAllGames.trigger("click");
  1264. refreshSingleColumnSize()
  1265. markJoinedGames();
  1266. applyOpenGameFilters();
  1267. }
  1268. });
  1269. }
  1270.  
  1271. function hideRightColumn() {
  1272. if (isEnabled('scrollGames')) {
  1273. $(".showSide").css("display", "none");
  1274. createSelector(".MainColumn", "margin: auto;");
  1275. createSelector(".MainColumn", "max-width: 800px;");
  1276. createSelector(".MainColumn", "width: 60%!important;");
  1277. createSelector(".MainColumn", "float: none !important;");
  1278. createSelector(".MainColumn", "min-width: 600px !important;");
  1279. } else {
  1280. $(".SideColumn").css("display", "none");
  1281. $(".MainColumn").css("width", "100%");
  1282. $(".MainColumn").css("max-width", "800px");
  1283. }
  1284. }
  1285.  
  1286. function registerGameTabClick() {
  1287. if (lastClick - new Date() > 2000) {
  1288. openGamesTable.scrollTop(0);
  1289. lastClick = new Date();
  1290. }
  1291. markJoinedGames();
  1292. }
  1293.  
  1294. function registerClanThread() {
  1295. var id = location.href.replace(/.*warlight[.]net\/Discussion\/[?]ID=/, "");
  1296. var data = localStorage.getItem('clanForumThreadsTime');
  1297. if (data != null) {
  1298. data = JSON.parse(data)
  1299. } else {
  1300. data = [];
  1301. }
  1302. var found = false;
  1303. $.each(data, function (key, val) {
  1304. if (val.id == id) {
  1305. data[key] = {id: id, date:new Date()};
  1306. found = true;
  1307. }
  1308. });
  1309. if (!found) {
  1310. data.push({id: id, date: new Date()});
  1311. }
  1312. localStorage.setItem('clanForumThreadsTime', JSON.stringify(data))
  1313. }
  1314.  
  1315. function updateOpenGamesCounter() {
  1316. var visibleGames = $("#OpenGamesTable .GameRow:not('.hidden')").length;
  1317. var active = $("#OpenGamesTable .ui-buttonset .ui-state-active").text();
  1318.  
  1319. if (active.indexOf('Both') > -1) {
  1320. //Both
  1321. $("#OpenGamesTable .ui-buttonset .ui-state-active span").text('Both (' + visibleGames + ')')
  1322. } else if (active.indexOf('Real') > -1) {
  1323. //Real
  1324. $("#OpenGamesTable .ui-buttonset .ui-state-active span").text('Real-Time (' + visibleGames + ')')
  1325. } else {
  1326. //Multi-Day
  1327. $("#OpenGamesTable .ui-buttonset .ui-state-active span").text('Multi-Day (' + visibleGames + ')')
  1328. }
  1329. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址