Tidy up your Dashboard

Customizable Userscript which tidies up your Dashboard!

当前为 2015-08-30 提交的版本,查看 最新版本

  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.2.5
  8. // @icon http://i.imgur.com/XzA5qMO.png
  9. // ==/UserScript==
  10.  
  11. var lastRefresh;
  12. var styleInterval;
  13. var myGamesTable = $("#MyGamesTable");
  14. var openGamesTable = $("#OpenGamesTable");
  15. var promotedGamesTable = $("#PromotedGamesTable");
  16. var lastClick = new Date();
  17.  
  18. var scrollGames;
  19. var autoRefreshOnFocus;
  20. var highlightTournaments;
  21. var hideMyGamesIcons;
  22. var hideCoinSymbol;
  23. var highlightNewForumPosts;
  24. var showOpenGamesTab;
  25. var hideRightColumn;
  26. var showOpenGamesFilter;
  27. var openGamesFilters;
  28.  
  29. var showGamesActive = "ShowMyGames";
  30. var showAllGames = "";
  31. var showAllCoinGames = "";
  32.  
  33. var multiOpenGames;
  34. var realOpenGames;
  35. var bothOpenGames;
  36. readLocalstorage();
  37. setGlobalStyles();
  38. setupUserscriptMenu();
  39.  
  40. if (location.href.match(/.*warlight[.]net\/MultiPlayer.*/)) {
  41. /** Show open Games in Tab-Bar
  42. *
  43. */
  44. if(showOpenGamesTab) {
  45. $("#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>')
  46. if (location.href.match(/.*warlight[.]net\/MultiPlayer\/OpenGames.*/)) {
  47. $("#openGamesTab").addClass("SubTabCellSelected");
  48. $("#openGamesTab").prev().children().css("visibility","visible")
  49. $("#openGamesTab").next().children().css("visibility","visible")
  50. }
  51. }
  52. }
  53.  
  54. if (location.href.match(/.*warlight[.]net\/MultiPlayer\/#?$/)) {
  55. setupRefresh();
  56. expandGames();
  57. markJoinedGames();
  58. hideBlacklistedThreads();
  59.  
  60. /**
  61. * Open Games Filter
  62. */
  63. if (showOpenGamesFilter) {
  64. //
  65. $("#OpenGamesTable thead tr td").prepend('<a id="editFilters" style="color:#DDDDDD;font-size: 14px;float: right;">▼</a>');
  66. var filters_body = "";
  67. filters_body += '<label for="hideTeam">Hide Team Games</label><input type="checkbox" id="hideTeam"><br>';
  68. filters_body += '<label for="hideFFA">Hide FFA Games</label><input type="checkbox" id="hideFFA"><br>';
  69. filters_body += '<label for="hide1v1">Hide 1 v 1 Games</label><input type="checkbox" id="hide1v1"><br>';
  70. filters_body += '<label for="hideCustomScenario">Hide Custom Scenario Games</label><input type="checkbox" id="hideCustomScenario"><br>';
  71. filters_body += '<label for="hidePractice">Hide Practice Games</label><input type="checkbox" id="hidePractice"><br>';
  72. filters_body += '<label for="hideLuck" style="width:169px">Hide luck greater than</label><input type="text" id="hideLuck"><br>';
  73. filters_body += '<div class="close-userscript">Close and Apply</div>';
  74. $("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>");
  75. createSelector('.popup input#hideLuck', 'display: inline-block;background: none;border-top: none;width: 31px;border-left: none;border-right: none;color: white;font-size: 15px;border-bottom: 1px white dashed;font-family: Verdana;padding: 0 5px 0 5px;text-align: center;');
  76. $("#hideLuck").after("%");
  77. createSelector('.ui-button-text-only .ui-button-text', 'padding: .4em 0.8em;');
  78. createSelector('#editFilters:hover', 'cursor:pointer');
  79.  
  80. $(".filters-show").on("change", function () {
  81. storeFilterVariables();
  82. });
  83. $("#editFilters").on("click", function () {
  84. $(".filters-show").fadeIn();
  85. $(".overlay").fadeIn();
  86. });
  87. $(".close-userscript").on("click", function () {
  88. $(".filters-show").fadeOut();
  89. $(".overlay").fadeOut();
  90. refreshAllGames();
  91. });
  92.  
  93. $(".close-popup-img").on("click", function () {
  94. $(".overlay").fadeOut();
  95. $(".popup").fadeOut();
  96. });
  97.  
  98. updateFilterSettings();
  99. }
  100. /**
  101. * Hide coin Symbol
  102. */
  103. if (hideCoinSymbol) {
  104. createSelector('#PromotedGamesTable td:last-of-type a img', 'display:none');
  105. createSelector("#MyGamesTable td > a > img", 'display:none')
  106. }
  107.  
  108. /**
  109. * Highlight Tournaments
  110. */
  111. if (highlightTournaments) {
  112. createSelector("#MyTournamentsTable tbody", "background:#4C4C33;");
  113. }
  114.  
  115. /**
  116. * Hide coin Game Icons
  117. */
  118. if (hideMyGamesIcons) {
  119. createSelector("#MyGamesTable td div img, #MyGamesTable td div a img", "display:none;");
  120. }
  121.  
  122. /**
  123. * Highlight Clan Forum Posts
  124. */
  125. if (highlightNewForumPosts) {
  126. var regex1 = /.* commented [\n \t]+/;
  127. var regex2 = / ago/;
  128.  
  129. var regex3 = /.*\/Forum\//;
  130. var regex4 = /-.*/;
  131. var data = localStorage.getItem('clanForumThreadsTime');
  132. if(data != null) {
  133. data = JSON.parse(data)
  134. } else if(data == null){
  135. data = [];
  136. $.each($('#ClanForumTable tbody tr'), function (index, row) {
  137. if($(row).find('td a')[0].href.match(/.*Forum\/[0-9]+/)) {
  138. var id = $(row).find('td a')[0].href.replace(regex3, "").replace(regex4, "");
  139. data.push({id: id, date: new Date()});
  140. }
  141. });
  142. localStorage.setItem('clanForumThreadsTime', JSON.stringify(data))
  143. }
  144.  
  145. $.each($('#ClanForumTable tbody tr'), function (index, row) {
  146. if($(row).find('td a')[0].href.match(/.*Forum\/[0-9]+/)) {
  147. var lastComment = $(row).find('td span').text().trim().replace(regex1, "").replace(regex2, "");
  148.  
  149. var id = $(row).find('td a')[0].href.replace(regex3, "").replace(regex4, "");
  150.  
  151. var found = false;
  152. $.each(data, function(key, val) {
  153. if(val.id == id) {
  154. found = true;
  155. if(getDate(lastComment) > new Date(val.date)) {
  156. $(row).css('background', '#4C4C33');
  157. }
  158. }
  159. });
  160. if(!found) {
  161. $(row).css('background', '#4C4C33');
  162. }
  163. }
  164. });
  165. }
  166.  
  167.  
  168.  
  169. /**
  170. * Basic CSS
  171. */
  172. createSelector(".GameRow a", "font-size:16px !important;");
  173. 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;");
  174. createSelector("#MyGamesTable td span a img, #MyGamesTable td span a img", "display:inherit;");
  175. createSelector(".GameRow:hover", "background-color:rgb(50, 50, 50);cursor:pointer;");
  176. createSelector(".GameRow a:hover", "text-decoration:none;");
  177. createSelector(".TournamentRow a:hover", "text-decoration:none;");
  178. createSelector(".TournamentRow:hover", "background-color:rgb(50, 50, 50);cursor:pointer;");
  179. createSelector(".ui-buttonset label", "font-size:11px;");
  180. createSelector("#OpenGamesTable label:hover", " border: 1px solid #59b4d4;background: #0078a3 50% 50% repeat-x;font-weight: bold;color: #ffffff;");
  181. createSelector("#OpenGamesTable td:last-child,#MyGamesTable td:last-child, #PromotedGamesTable td:last-child", "position: relative;");
  182. 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;");
  183. 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;");
  184. createSelector(".loading img", "position: absolute;top: 50%;left: 50%;margin-left: -16px;margin-top: -16px;");
  185. createSelector("img", "position: relative;z-index:50;");
  186. createSelector("input", "z-index: 1000;position: relative;");
  187. createSelector(".showGames table thead td", "display:table-cell;width:100%;");
  188. createSelector(".showGames table thead tr", "display:table;width:100%;");
  189. createSelector(".showGames table tbody", "display:table;width:100%;");
  190.  
  191. $.each($(".TournamentRow td"), function () {
  192. $(this).find("font:first-of-type").appendTo($(this).find("a")).css("font-size", "10px");
  193. });
  194.  
  195.  
  196.  
  197. /**
  198. * Fixed window with Scrollable Games
  199. */
  200. if (scrollGames) {
  201. var gameButtons = '<div style="margin: 10px;" id="switchGameRadio" class="ui-buttonset"><input type="radio" id="ShowMyGames" name="switchGames" checked="checked" class="ui-helper-hidden-accessible"><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><input type="radio" id="ShowOpenGames" name="switchGames" class="ui-helper-hidden-accessible"><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><input type="radio" id="ShowCoinGames" name="switchGames" class="ui-helper-hidden-accessible"><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></div>';
  202.  
  203. var mainColumn = $(".MainColumn ");
  204. mainColumn.prepend('<div class="showGamesContainer">' + gameButtons + '<div class="showGames"></div></div>');
  205. myGamesTable.appendTo(".showGames");
  206.  
  207. mainColumn.after('<div class="showSide"></div>');
  208. $(".SideColumn").appendTo(".showSide");
  209.  
  210. /**
  211. * Fixed Titles in Side Column
  212. */
  213. var blogTable = $("#BlogTable");
  214. var realTimeLadderTable = $("#RealTimeLadderTable");
  215. var forumTable = $("#ForumTable");
  216. var clanForumTable = $("#ClanForumTable");
  217. var mapOfTheWeekTable = $("#MapOfTheWeekTable");
  218. var leaderboardTable = $("#LeaderboardTable");
  219. var myTournamentsTable = $("#MyTournamentsTable");
  220.  
  221. blogTable.before("<div class='followMeBar'>" + blogTable.find("thead > tr > td").html() + "</div>");
  222. realTimeLadderTable.before("<div class='followMeBar'>" + realTimeLadderTable.find("thead > tr > td").html() + "</div>");
  223. forumTable.before("<div class='followMeBar'>" + forumTable.find("thead > tr > td").html() + "</div>");
  224. clanForumTable.before("<div class='followMeBar'>" + clanForumTable.find("thead > tr > td").html() + "</div>");
  225. mapOfTheWeekTable.before("<div class='followMeBar'>" + mapOfTheWeekTable.find("thead > tr > td").html() + "</div>");
  226. leaderboardTable.before("<div class='followMeBar'>" + leaderboardTable.find("thead > tr > td").html() + "</div>");
  227. myTournamentsTable.before("<div class='followMeBar'>" + myTournamentsTable.find("thead > tr > td").html() + "</div>");
  228.  
  229. 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");
  230. var top = parseInt($(".showSide").offset().top) + parseInt(43);
  231. createSelector(".followMeBar.fixed", "position: fixed;top: " + top + "px;z-index: 0;z-index:100;");
  232. createSelector(".followMeBar.fixed.absolute", "position: absolute;");
  233.  
  234. createSelector(".showSide", "overflow-y:scroll;float: left;margin-top: 43px;padding-right: 6px;");
  235. createSelector(".showSide thead", "display:none");
  236. createSelector(".showSide table", "border-top-right-radius:0;border-top-left-radius:0");
  237.  
  238. /**
  239. * Fixed Column CSS
  240. */
  241. createSelector("#switchGameRadio label", "margin-left: 6px !important");
  242. createSelector(".showGames table", "display:block !important");
  243. 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);");
  244. createSelector("#MyGamesTable, #PromotedGamesTable, #OpenGamesTable", "display:none");
  245. createSelector("#MainSiteContent > table > tbody > tr > td", "width:100%");
  246. createSelector(".MainColumn", "min-width:535px");
  247. createSelector(".MainColumn", "width:40.55% !important");
  248. createSelector(".SideColumn", "float:left !important");
  249. createSelector("h2 + span", "margin-right: 50px;");
  250. createSelector("body", "overflow:hidden");
  251. createSelector(".SideColumn", "width: 100% !important;");
  252. createSelector("#MyGamesFilter", "width:200px");
  253. createSelector(".showGames table thead", "position:fixed; z-index:500; border-top-left-radius:8px");
  254. createSelector(".showGames table", "display:block; overflow-y:scroll; overflow-x:hidden; border:1px gray solid; border-radius:8px");
  255. createSelector(".adsbygoogle", "margin-top: 25px;");
  256. 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");
  257. createSelector("#refreshAll", "position: absolute;top: 20px;right: 31px");
  258. createSelector("#fakeOpenGameMenu label", "margin-right:2px");
  259. createSelector("#RestoreLotteryGamesBtn", "display:none");
  260.  
  261.  
  262.  
  263. new StickyTitles(jQuery(".followMeBar")).load();
  264. refreshSingleColumnSize();
  265.  
  266. $("#switchGameRadio").find("label").on("click", function () {
  267. var newShowGames = $(this).attr("for");
  268. if (newShowGames != showGamesActive) {
  269. $.each($("#switchGameRadio").find("label"), function () {
  270. $(this).removeClass("ui-state-active");
  271. });
  272. $(this).addClass("ui-state-active");
  273.  
  274. if (newShowGames == "ShowMyGames") {
  275. showGamesActive = newShowGames;
  276. promotedGamesTable.appendTo("body");
  277. openGamesTable.appendTo("body");
  278. myGamesTable.appendTo(".showGames");
  279. } else if (newShowGames == "ShowCoinGames") {
  280. showGamesActive = newShowGames;
  281. myGamesTable.appendTo("body");
  282. openGamesTable.appendTo("body");
  283. promotedGamesTable.appendTo(".showGames");
  284. } else if (newShowGames == "ShowOpenGames") {
  285. showGamesActive = newShowGames;
  286. myGamesTable.appendTo("body");
  287. promotedGamesTable.appendTo("body");
  288. openGamesTable.appendTo(".showGames");
  289. }
  290.  
  291. showAllGames.trigger("click");
  292. refreshSingleColumnSize()
  293. markJoinedGames();
  294. applyOpenGameFilters();
  295. }
  296. });
  297. }
  298. /** Hide Right column
  299. *
  300. */
  301. if(hideRightColumn) {
  302. if(scrollGames) {
  303. $(".showSide").css("display", "none");
  304. createSelector(".MainColumn", "margin: auto;");
  305. createSelector(".MainColumn", "max-width: 800px;");
  306. createSelector(".MainColumn", "width: 60%!important;");
  307. createSelector(".MainColumn", "float: none !important;");
  308. createSelector(".MainColumn", "min-width: 600px !important;");
  309. } else {
  310. $(".SideColumn").css("display", "none");
  311. $(".MainColumn").css("width", "100%");
  312. $(".MainColumn").css("max-width", "800px");
  313. }
  314. }
  315.  
  316. $("label[for='MultiDayRadio']").on("click", function () {
  317. if (lastClick - new Date() > 2000) {
  318. openGamesTable.scrollTop(0);
  319. lastClick = new Date();
  320. }
  321. markJoinedGames();
  322.  
  323. });
  324. $("label[for='RealTimeRadio']").on("click", function () {
  325. if (lastClick - new Date() > 2000) {
  326. openGamesTable.scrollTop(0);
  327. lastClick = new Date();
  328. }
  329. markJoinedGames();
  330. });
  331. $("label[for='BothRadio']").on("click", function () {
  332. if (lastClick - new Date() > 2000) {
  333. openGamesTable.scrollTop(0);
  334. lastClick = new Date();
  335. }
  336. markJoinedGames();
  337. });
  338.  
  339. $(window).resize(function () {
  340. if (scrollGames) {
  341. refreshSingleColumnSize();
  342. }
  343. });
  344.  
  345. }
  346.  
  347.  
  348.  
  349. if (location.href.match(/.*warlight[.]net\/Discussion/)) {
  350. var id = location.href.replace(/.*warlight[.]net\/Discussion\/[?]ID=/, "");
  351. var data = localStorage.getItem('clanForumThreadsTime');
  352. if(data != null) {
  353. data = JSON.parse(data)
  354. } else {
  355. data = [];
  356. }
  357. var found = false;
  358. $.each(data, function(key, val) {
  359. if(val.id == id) {
  360. data[key] = {id: id, date:new Date()};
  361. found = true;
  362. }
  363. });
  364. if(!found) {
  365. data.push({id: id, date: new Date()});
  366. }
  367. localStorage.setItem('clanForumThreadsTime', JSON.stringify(data))
  368. }
  369.  
  370.  
  371.  
  372. /**
  373. * Reads the User-Settings from Localstorage
  374. */
  375. function readLocalstorage() {
  376.  
  377. //Settings
  378. scrollGames = localStorage.getItem("scrollGames") == "true";
  379. autoRefreshOnFocus = localStorage.getItem("autoRefreshOnFocus") == "true";
  380. highlightTournaments = localStorage.getItem("highlightTournaments") == "true";
  381. hideMyGamesIcons = localStorage.getItem("hideMyGamesIcons") == "true";
  382. highlightNewForumPosts = localStorage.getItem("highlightNewForumPosts") == "true";
  383. showOpenGamesTab = localStorage.getItem("showOpenGamesTab") == "true";
  384. hideRightColumn = localStorage.getItem("hideRightColumn") == "true";
  385. showOpenGamesFilter = localStorage.getItem("showOpenGamesFilter") == "true";
  386.  
  387. //Filters
  388. var filters = localStorage.getItem("openGamesFilters");
  389.  
  390. if(filters) {
  391. openGamesFilters = $.parseJSON(filters);
  392. } else {
  393. openGamesFilters = {};
  394. }
  395.  
  396.  
  397. hideCoinSymbol = true;
  398. }
  399.  
  400. /**
  401. * Creates the Userscript-Menu
  402. */
  403. function setupUserscriptMenu() {
  404. var inputs = "";
  405. inputs += '<label for="scrollGames">Fixed Window with scrollable Games</label><input type="checkbox" id="scrollGames"><br>';
  406. inputs += '<label for="hideMyGamesIcons">Hide Icons in "My Games"</label><input type="checkbox" id="hideMyGamesIcons"><br>';
  407. inputs += '<label for="autoRefreshOnFocus">Automatically refresh Games on Tab-Focus</label><input type="checkbox" id="autoRefreshOnFocus"><br>';
  408. inputs += '<label for="highlightTournaments">Highlight Tournament invites</label><input type="checkbox" id="highlightTournaments"><br>';
  409. inputs += '<label for="highlightNewForumPosts">Highlight new Clan Posts</label><input type="checkbox" id="highlightNewForumPosts"><br>';
  410. inputs += '<label for="showOpenGamesTab">Show Open Games Tab in Menu Bar</label><input type="checkbox" id="showOpenGamesTab"><br>';
  411. inputs += '<label for="hideRightColumn">Hide Right Column</label><input type="checkbox" id="hideRightColumn"><br>';
  412. inputs += '<label for="showOpenGamesFilter">Enable Open Games Filter</label><input type="checkbox" id="showOpenGamesFilter"><br>';
  413. inputs += '<div class="close-userscript">Close and Refresh</div>';
  414.  
  415. $("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>");
  416. $(".userscript-show").on("change", function () {
  417. storeSettingsVariables();
  418. });
  419. $("#TopRightDropDown").find("ul").append('<li><div class="userscript-menu">Userscript</div></li>');
  420.  
  421. $(".userscript-menu").on("click", function () {
  422. $(".userscript-show").fadeIn();
  423. $(".overlay").fadeIn();
  424. $("#TopRightDropDown").fadeOut();
  425. });
  426.  
  427. $(".close-userscript").on("click", function () {
  428. $(".userscript-show").fadeOut();
  429. $(".overlay").fadeOut();
  430. location.reload();
  431. });
  432.  
  433. $(".close-popup-img").on("click", function () {
  434. $(".userscript-show").fadeOut();
  435. $(".overlay").fadeOut();
  436. });
  437.  
  438. checkUserscriptMenuButtons();
  439.  
  440. }
  441.  
  442. function checkUserscriptMenuButtons() {
  443. $("#scrollGames").prop("checked", scrollGames);
  444. $("#autoRefreshOnFocus").prop("checked", autoRefreshOnFocus);
  445. $("#highlightTournaments").prop("checked", highlightTournaments);
  446. $("#hideMyGamesIcons").prop("checked", hideMyGamesIcons);
  447. $("#highlightNewForumPosts").prop("checked", highlightNewForumPosts);
  448. $("#showOpenGamesTab").prop("checked", showOpenGamesTab);
  449. $("#hideRightColumn").prop("checked", hideRightColumn);
  450. $("#showOpenGamesFilter").prop("checked", showOpenGamesFilter);
  451. }
  452.  
  453.  
  454. /**
  455. * Creates fixed Titles
  456. * @param stickies
  457. * @constructor
  458. */
  459. function StickyTitles(stickies) {
  460. var thisObj = this;
  461. thisObj.load = function () {
  462. stickies.each(function () {
  463. var thisSticky = $(this).wrap('<div class="followWrap" />');
  464. thisSticky.parent().height(thisSticky.outerHeight());
  465. var pos = parseInt(thisSticky.offset().top) - parseInt($(".showSide").offset().top);
  466. $.data(thisSticky[0], 'pos', pos);
  467. });
  468. $(".showSide").off("scroll.stickies").on("scroll.stickies", function () {
  469. thisObj.scroll();
  470. });
  471. };
  472.  
  473. thisObj.scroll = function () {
  474. stickies.each(function (i) {
  475. var thisSticky = $(this),
  476. nextSticky = stickies.eq(i + 1),
  477. prevSticky = stickies.eq(i - 1),
  478. pos = $.data(thisSticky[0], 'pos');
  479. var showSide = $(".showSide");
  480. if (pos <= showSide.scrollTop()) {
  481. thisSticky.addClass("fixed");
  482. if (nextSticky.length > 0 && thisSticky.offset().top >= $.data(nextSticky[0], 'pos') - thisSticky.outerHeight()) {
  483. thisSticky.addClass("absolute").css("top", jQuery.data(nextSticky[0], 'pos') - thisSticky.outerHeight());
  484. }
  485. } else {
  486. thisSticky.removeClass("fixed");
  487. if (prevSticky.length > 0 && showSide.scrollTop() <= $.data(thisSticky[0], 'pos') - prevSticky.outerHeight()) {
  488. prevSticky.removeClass("absolute").removeAttr("style");
  489. }
  490. }
  491. });
  492. }
  493. }
  494.  
  495. jQuery.fn.outerHTML = function (s) {
  496. return s ? this.before(s).remove() : jQuery("<p>").append(this.eq(0).clone()).html();
  497. };
  498.  
  499.  
  500. /**
  501. * Triggers a click on the expand Games Button
  502. */
  503. function triggerExpandGames() {
  504. if (showAllGames == "" || showAllGames.length == 0) {
  505. showAllGames = $("#ShowMoreOpenGamesLink");
  506. showAllGames.trigger("click");
  507. }
  508. if (showAllCoinGames == "") {
  509. showAllCoinGames = $("#ShowMorePromotedGamesLink");
  510. showAllCoinGames.trigger("click");
  511. }
  512. //$("label[for='MultiDayRadio']").trigger("click");
  513.  
  514. }
  515.  
  516. function markJoinedGames() {
  517. var gamesSwitch = setInterval(function(){
  518. applyOpenGameFilters();
  519. var name = $(".TopRightBar a:nth-of-type(2)").text();
  520. var playerLabel = '<span style="font-size:12px; color:gray"> You already joined</span>'
  521. $.each($("#OpenGamesTable tr"), function(key, tableRow) {
  522. $.each($(tableRow).find("span span"), function(key2, player) {
  523. if($(player).attr("title") == name && $(tableRow).html().indexOf("You already joined") < 0) {
  524. $(tableRow).find("td:nth-of-type(2) a").append(playerLabel)
  525. }
  526. });
  527.  
  528. })
  529. }, 5);
  530. setTimeout(function() {
  531. clearInterval(gamesSwitch);
  532. }, 400)
  533. }
  534.  
  535. /**
  536. * Delayed function for expanding Games
  537. */
  538.  
  539. function expandGames() {
  540. numOfGames = 0;
  541. styleInterval = setInterval(triggerExpandGames, 100);
  542. setTimeout(function () {
  543. clearInterval(styleInterval);
  544. }, 3000);
  545. }
  546.  
  547. /**
  548. * Stores User-Settings to local Storage
  549. */
  550. function storeSettingsVariables() {
  551. localStorage.setItem("autoRefreshOnFocus", $("#autoRefreshOnFocus").prop("checked"));
  552. localStorage.setItem("highlightTournaments", $("#highlightTournaments").prop("checked"));
  553. localStorage.setItem("hideMyGamesIcons", $("#hideMyGamesIcons").prop("checked"));
  554. localStorage.setItem("scrollGames", $("#scrollGames").prop("checked"));
  555. localStorage.setItem("highlightNewForumPosts", $("#highlightNewForumPosts").prop("checked"));
  556. localStorage.setItem("showOpenGamesTab", $("#showOpenGamesTab").prop("checked"));
  557. localStorage.setItem("hideRightColumn", $("#hideRightColumn").prop("checked"));
  558. localStorage.setItem("showOpenGamesFilter", $("#showOpenGamesFilter").prop("checked"));
  559. }
  560.  
  561. /**
  562. * Refreshes Width & Height of Columns
  563. */
  564. function refreshSingleColumnSize() {
  565. var showSide = $(".showSide");
  566. var showGames = $(".showGames");
  567. showSide.scrollTop(0);
  568. /**
  569. * Sticky Titles
  570. */
  571. $(".followMeBar").each(function () {
  572. $(this).removeClass("fixed");
  573. if ($(this).parent().hasClass("followWrap")) {
  574. $(this).unwrap();
  575. }
  576. var thisSticky = $(this).wrap('<div class="followWrap" />');
  577. thisSticky.parent().height(thisSticky.outerHeight());
  578.  
  579. var pos = parseInt(thisSticky.offset().top) - parseInt(showSide.offset().top);
  580. $.data(thisSticky[0], 'pos', pos);
  581. });
  582. var width = $("#ForumTable").width();
  583. createSelector(".followMeBar", "width:" + width + "px;");
  584.  
  585. showGames.find("table").css({
  586. height: window.innerHeight - 150
  587. });
  588. showGames.find("table thead").css({
  589. width: showGames.width() - 20
  590. });
  591. var height = showGames.find("table thead").height() + 6;
  592. createSelector(".showGames table tbody tr:first-of-type td", "padding-top:" + height + "px");
  593.  
  594.  
  595. showSide.css({
  596. height: window.innerHeight - 150
  597. });
  598. showGames.find("table tbody tr:first-of-type td").css("padding-top", showGames.find("table thead").height() + 6)
  599.  
  600. }
  601.  
  602. /**
  603. * Create a CSS selector
  604. * @param name The name of the object, which the rules are applied to
  605. * @param rules The CSS rules
  606. */
  607. function createSelector(name, rules) {
  608. var style = document.createElement('style');
  609. style.type = 'text/css';
  610. document.getElementsByTagName('head')[0].appendChild(style);
  611. if (!(style.sheet || {}).insertRule) {
  612. (style.styleSheet || style.sheet).addRule(name, rules);
  613. } else {
  614. style.sheet.insertRule(name + "{" + rules + "}", 0);
  615. }
  616. }
  617.  
  618. /**
  619. * Reloads all Games
  620. */
  621.  
  622. function refreshAllGames() {
  623.  
  624. myGamesTable.find("tbody").fadeTo('slow', 0.15);
  625. openGamesTable.find("tbody").fadeTo('slow', 0.15);
  626. promotedGamesTable.find("tbody").fadeTo('slow', 0.15);
  627.  
  628. var page = $('<div />').load('https://www.warlight.net/MultiPlayer/ ', function () {
  629. var myGames = page.find('#MyGamesTable tbody tr');
  630. //var openGames = page.find('#OpenGamesTable tbody tr');
  631. var promotedGames = page.find('#PromotedGamesTable tbody tr');
  632. showAllGames = page.find("#ShowMoreOpenGamesLink");
  633.  
  634. promotedGamesTable.find("tbody tr").remove();
  635.  
  636. $.each(myGamesTable.find("tbody tr"), function (key, value) {
  637. if ($(value).html().indexOf("PastGames") == -1) {
  638. $(value).remove();
  639. }
  640. });
  641.  
  642. myGamesTable.find("tbody").prepend(myGames);
  643. //$("#OpenGamesTable").find("tbody").prepend(openGames);
  644. promotedGamesTable.find("tbody").prepend(promotedGames);
  645. $("#MorePromotedGamesHorizontalRow").remove();
  646.  
  647. $("#ShowMorePromotedGamesLinkContainer").remove();
  648.  
  649. $.each($(".TournamentRow td"), function () {
  650. $(this).find("font:first-of-type").appendTo($(this).find("a")).css("font-size", "10px");
  651. });
  652.  
  653.  
  654. myGamesTable.find("tbody").fadeTo('slow', 1);
  655. //openGamesTable.find("tbody").fadeTo('slow', 1);
  656. promotedGamesTable.find("tbody").fadeTo('slow', 1);
  657. markJoinedGames();
  658.  
  659. if (scrollGames) {
  660. refreshSingleColumnSize();
  661. openGamesTable.scrollTop(0);
  662. myGamesTable.scrollTop(0);
  663. promotedGamesTable.scrollTop(0);
  664. }
  665.  
  666. });
  667.  
  668. var activeTab;
  669. var active = $("#OpenGamesTable .ui-buttonset .ui-state-active").text();
  670.  
  671. if (active.indexOf('Both') > -1) {
  672. activeTab = "BothRadio";
  673. } else if (active.indexOf('Real') > -1) {
  674. activeTab = "RealTimeRadio";
  675. } else {
  676. activeTab = "MultiDayRadio";
  677. }
  678. //Reload open games
  679. var ifr = $('<iframe/>', {
  680. id: 'iframeiii',
  681. src: 'https://www.warlight.net/MultiPlayer/OpenGames',
  682. style: 'display:none;position:fixed;z-index: 100000;right: 0;top:0;width:500px;height:550px;opacity:1',
  683. load: function () {
  684. setTimeout(function () {
  685. $("#iframeiii").contents().find("label[for='MultiDayRadio']").trigger('click');
  686. setTimeout(function () {
  687. multiOpenGames = $("#iframeiii").contents().find('#OpenGamesTable tbody tr').addClass('multiOpenGames');
  688. $("#iframeiii").contents().find("label[for='RealTimeRadio']").trigger('click');
  689. setTimeout(function () {
  690. realOpenGames = $("#iframeiii").contents().find('#OpenGamesTable tbody tr').addClass('realOpenGames');
  691. $("#iframeiii").contents().find("label[for='BothRadio']").trigger('click');
  692. setTimeout(function () {
  693.  
  694. 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>';
  695.  
  696. bothOpenGames = $("#iframeiii").contents().find('#OpenGamesTable tbody tr').addClass('bothOpenGames');
  697. $("#OpenGamesTable thead tr td .ui-buttonset").remove();
  698. $("#OpenGamesTable thead tr td").append(openGamesMenu);
  699. $("#OpenGamesTable tbody tr").remove();
  700.  
  701.  
  702. $("#OpenGamesTable tbody").append(multiOpenGames);
  703. $("#OpenGamesTable tbody").append(realOpenGames);
  704. $("#OpenGamesTable tbody").append(bothOpenGames);
  705. $("RestoreLotteryGamesBtn").remove();
  706. //$(".multiOpenGames").hide();
  707. //$(".realOpenGames").hide();
  708. //$(".bothOpenGames").hide();
  709.  
  710. $("label[for='MultiDayRadio']").on("click", function () {
  711. $(".multiOpenGames").show();
  712. $(".multiOpenGames").prependTo("#OpenGamesTable tbody");
  713. $(".realOpenGames").hide();
  714. $(".bothOpenGames").hide();
  715. openGamesTable.scrollTop(0);
  716. $(this).addClass('ui-state-active');
  717. $("label[for='BothRadio']").removeClass('ui-state-active');
  718. $("label[for='RealTimeRadio']").removeClass('ui-state-active');
  719.  
  720. });
  721. $("label[for='RealTimeRadio']").on("click", function () {
  722. openGamesTable.scrollTop(0);
  723. $(".multiOpenGames").hide();
  724. $(".realOpenGames").show();
  725. $(".realOpenGames").prependTo("#OpenGamesTable tbody");
  726. $(".bothOpenGames").hide();
  727. $(this).addClass('ui-state-active');
  728. $("label[for='MultiDayRadio']").removeClass('ui-state-active');
  729. $("label[for='BothRadio']").removeClass('ui-state-active');
  730. });
  731. $("label[for='BothRadio']").on("click", function () {
  732. openGamesTable.scrollTop(0);
  733. $(".multiOpenGames").hide();
  734. $(".realOpenGames").hide();
  735. $(".bothOpenGames").show();
  736. $(".bothOpenGames").prependTo("#OpenGamesTable tbody");
  737. $(this).addClass('ui-state-active');
  738. $("label[for='MultiDayRadio']").removeClass('ui-state-active');
  739. $("label[for='RealTimeRadio']").removeClass('ui-state-active');
  740. });
  741.  
  742. $($(".realOpenGames")[0]).find("td").css("padding-top", $(".showGames").find("table thead").height() + 6);
  743. $($(".bothOpenGames")[0]).find("td").css("padding-top", $(".showGames").find("table thead").height() + 6)
  744. var activeT = "label[for='" + activeTab + "']";
  745. $("#OpenGamesTable").hide();
  746. $(activeT).trigger('click');
  747. $("#OpenGamesTable").show();
  748. openGamesTable.find("tbody").fadeTo('slow', 1);
  749. $("#iframeiii").remove();
  750. markJoinedGames();
  751.  
  752. }, 100);
  753. }, 100);
  754. }, 100);
  755. }, 100);
  756.  
  757. }
  758. });
  759. $('body').append(ifr);
  760. }
  761.  
  762. /**
  763. * Setups the refresh functionality
  764. */
  765. function setupRefresh() {
  766. lastRefresh = new Date();
  767. var oldRefreshBtn = $("#RefreshBtn");
  768. var oldRefreshBtn2 = $("#RefreshBtn2");
  769. if (oldRefreshBtn.length) {
  770. var newRefreshBtn = $("#refreshAll");
  771. oldRefreshBtn.replaceWith(oldRefreshBtn.clone().removeAttr("id").attr("id", "refreshAll").attr("value", "Refresh (R)"));
  772. newRefreshBtn.appendTo("body");
  773. $("#refreshAll").on("click", function () {
  774. if (new Date() - lastRefresh > 3000) {
  775. lastRefresh = new Date();
  776. refreshAllGames();
  777. }
  778. });
  779. } else if (oldRefreshBtn2.length) {
  780. var newRefreshBtn = $("#refreshAll");
  781. oldRefreshBtn2.replaceWith(oldRefreshBtn2.clone().removeAttr("id").attr("id", "refreshAll").attr("value", "Refresh (R)"));
  782. newRefreshBtn.appendTo("body");
  783. $("#refreshAll").on("click", function () {
  784. if (new Date() - lastRefresh > 3000) {
  785. lastRefresh = new Date();
  786. refreshAllGames();
  787. }
  788. });
  789. }
  790.  
  791. if (autoRefreshOnFocus) {
  792. $(window).on('focus', function () {
  793. if (new Date() - lastRefresh > 30000) {
  794. lastRefresh = new Date();
  795. refreshAllGames();
  796. }
  797. });
  798. }
  799.  
  800. $("body").keyup(function (event) {
  801. // "R" is pressed
  802. if (event.which == 82) {
  803. if (new Date() - lastRefresh > 3000) {
  804. lastRefresh = new Date();
  805. refreshAllGames();
  806. }
  807. }
  808. });
  809.  
  810. openGamesTable.prepend("<div class='loading loading-open'><img src='https://www.adobe.com/business/calculator/VIP/image/loader.gif' height='32' width='32'></div>");
  811. myGamesTable.prepend("<div class='loading loading-my'><img src='https://www.adobe.com/business/calculator/VIP/image/loader.gif' height='32' width='32'></div>");
  812. promotedGamesTable.prepend("<div class='loading loading-prom'><img src='https://www.adobe.com/business/calculator/VIP/image/loader.gif' height='32' width='32'></div>");
  813. }
  814.  
  815.  
  816. function getDate(text) {
  817. var date;
  818.  
  819. if (text.match(/[0-9]+ second/)) {
  820. date = new Date() - 1000;
  821.  
  822. } else if (text.match(/[0-9]+ seconds/)) {
  823. date = new Date() - text.match(/[0-9]+/) * 1000;
  824.  
  825. } else if (text.match(/[0-9]+ minute/)) {
  826. date = new Date() - text.match(/[0-9]+/) * 1000 * 60;
  827.  
  828. } else if (text.match(/[0-9]+ minutes/)) {
  829. date = new Date() - text.match(/[0-9]+/) * 1000 * 60;
  830.  
  831. } else if (text.match(/[0-9]+ hour/)) {
  832. date = new Date() - text.match(/[0-9]+/) * 1000 * 60 * 59;
  833.  
  834. } else if (text.match(/[0-9]+ hours/)) {
  835. date = new Date() - text.match(/[0-9]+/) * 1000 * 60 * 60;
  836.  
  837. } else if (text.match(/[0-9]+ day/)) {
  838. date = new Date() - text.match(/[0-9]+/) * 1000 * 60 * 60 * 36;
  839.  
  840. } else if (text.match(/[0-9]+ days/)) {
  841. date = new Date() - text.match(/[0-9]+/) * 1000 * 60 * 60 * 24;
  842.  
  843. } else if (text.match(/[0-9]+[\/][0-9]+[\/][0-9]+/)) {
  844. var split = text.split('/');
  845. date = new Date(split[2], split[0]-1, split[1]);
  846. date.setHours(0, 0, 0, 0);
  847. }
  848. return date;
  849. }
  850.  
  851.  
  852. var searches = 0;
  853. function filterMailTo() {
  854. if (searches == 0) {
  855. $($("#MainSiteContent div:nth-of-type(1)")[0]).children().remove()
  856. searches++;
  857. }
  858. var find = $("#search_input").val().toLowerCase()
  859. if(find.length > 1) {
  860. removeUncheckedMail()
  861. $.each(data_mail, function(index, val) {
  862. if($(val).text().toLowerCase().indexOf(find) > -1) {
  863. var id = $(val).attr("id").replace("Lbl_", "")
  864. if($("#Lbl_"+id).length == 0) {
  865. $($("#MainSiteContent div:nth-of-type(1)")[0]).append('<input type="checkbox" id="CB_' + id + '" onclick="PlayerClicked(' + id + ')">').append(val).append("<br>")
  866. }
  867. }
  868. })
  869. }
  870. else {
  871. removeUncheckedMail()
  872. }
  873. }
  874.  
  875. function hideBlacklistedThreads() {
  876. var ids = JSON.parse(localStorage.getItem("blackListedThreads"));
  877. $.each($("#ForumTable tr"), function(key, row) {
  878. var href = $(row).html().match(/href="\/([^"]*)"/m);
  879. if(href) {
  880. href = "/" + href[1]
  881. if($.inArray(href, ids) != -1) {
  882. $(row).remove()
  883. }
  884. }
  885. })
  886. }
  887.  
  888. function removeUncheckedMail() {
  889. $.each($($("#MainSiteContent div:nth-of-type(1)")[0]).find("label"), function(index, val) {
  890. var id = $(val).attr("id").replace("Lbl_", "")
  891. if( ! $('#CB_'+id).is(":checked")) {
  892. $(val).next().remove()
  893. $(val).prev().remove()
  894. $(val).remove()
  895. }
  896. })
  897. }
  898. var data_mail = []
  899. if (location.href.match(/.*warlight[.]net\/Discussion\/SendMail/)) {
  900. $($("#MainSiteContent div:nth-of-type(1)")[0]).before('<input id="search_input" placeholder="Filter" style="margin-bottom:10px">')
  901. $("#search_input").on("input", function() {
  902. filterMailTo()
  903. })
  904. $.each($($("#MainSiteContent div:nth-of-type(1)")[0]).find("label"), function(index, val) {
  905. data_mail.push($(val))
  906. });
  907.  
  908. }
  909.  
  910. function setGlobalStyles() {
  911. createSelector(".BootTimeLabel", "color:white !important;font-weight:normal!important;font-style:italic;font-size:13px!important;z-index:50;");
  912. createSelector(".userscript-menu", "display: block;color: #555;text-decoration: none;line-height: 18px;padding: 3px 15px;margin: 0;white-space: nowrap;");
  913. createSelector(".userscript-menu:hover", "cursor:pointer;background-color: #08C;color: #FFF;cursor: pointer;");
  914. createSelector(".popup", "position: fixed;width: 420px;left: 50%;background: #171717;margin-left: -250px;top: 100px;z-index: 50000001; color:white;padding:60px 30px 30px 30px;border: 2px solid gray;border-radius:8px");
  915. createSelector(".close-userscript", "margin-top: 40px;width: 100%;text-align: center;font-size: 15px;cursor: pointer;background: gray;line-height: 30px;border-radius: 8px;");
  916. createSelector(".close-popup-img", "float:right;margin:5px;cursor:pointer");
  917. createSelector(".popup label", "width: 80%;display: inline-block;font-size: 15px;margin: 5px;");
  918. createSelector(".popup input[type='checkbox']", "width: 20px;height: 20px;margin-left:30px;margin: 5px");
  919. createSelector(".overlay", "position: absolute;background: white;top: 0;left: 0;right: 0;bottom: 0;z-index: 50000000;opacity: 0.5;");
  920. createSelector(".popup .head", "position: absolute;height: 40px;background: #330000;width: 100%;left: 0;right: 0;top: 0;color: white;font-size: 15px;text-align: center;line-height: 40px;border-top-left-radius:8px;border-top-right-radius:8px;");
  921. createSelector(".userscript-show", "display:none");
  922. createSelector("#MorePromotedGamesHorizontalRow", "display:none");
  923. }
  924.  
  925. function hideFFAGames() {
  926. var hiddenGames = 0;
  927. $.each($("#OpenGamesTable tr"), function(key, tableRow) {
  928. if(rowIsFFAGame(tableRow) && $(tableRow).hasClass('GameRow')) {
  929. //$("#OpenGamesTable").append(tableRow);
  930. rowSlideUp(tableRow);
  931. hiddenGames++;
  932. }
  933. //var players = $(tableRow).find("td:nth-of-type(2) span span").length;
  934. //$(tableRow).find("td:nth-of-type(2) a").append(" " + players )
  935. });
  936. return hiddenGames;
  937. }
  938.  
  939. function hideTeamGames() {
  940. var hiddenGames = 0;
  941. $.each($("#OpenGamesTable tr"), function(key, tableRow) {
  942. if(rowIsTeamGame(tableRow) && $(tableRow).hasClass('GameRow')) {
  943. rowSlideUp(tableRow);
  944. hiddenGames++;
  945. }
  946. //var players = $(tableRow).find("td:nth-of-type(2) span span").length;
  947. //$(tableRow).find("td:nth-of-type(2) a").append(" " + players )
  948. });
  949. return hiddenGames;
  950. }
  951.  
  952. function hideGamesWithLuckOver(maxLuck) {
  953. var hiddenGames = 0;
  954. if(maxLuck < 100) {
  955. $.each($("#OpenGamesTable tr"), function(key, tableRow) {
  956. var luck = getLuckFromRow(tableRow);
  957. if(parseInt(luck) > maxLuck) {
  958. rowSlideUp(tableRow);
  959. hiddenGames++;
  960. }
  961. });
  962. }
  963. return hiddenGames;
  964. }
  965.  
  966. function hide1v1Games() {
  967. var hiddenGames = 0;
  968. $.each($("#OpenGamesTable tr"), function(key, tableRow) {
  969. if(rowIs1v1Game(tableRow) && $(tableRow).hasClass('GameRow')) {
  970. rowSlideUp(tableRow);
  971. hiddenGames++;
  972. }
  973. });
  974. return hiddenGames;
  975. }
  976.  
  977. function hideCustomScenarioGames() {
  978. var hiddenGames = 0;
  979. $.each($("#OpenGamesTable tr"), function(key, tableRow) {
  980. if(rowIsCustomScenarioGame(tableRow) && $(tableRow).hasClass('GameRow')) {
  981. rowSlideUp(tableRow);
  982. hiddenGames++;
  983. }
  984. //var players = $(tableRow).find("td:nth-of-type(2) span span").length;
  985. //$(tableRow).find("td:nth-of-type(2) a").append(" " + players )
  986. });
  987. return hiddenGames;
  988. }
  989.  
  990. function hidePracticeGames() {
  991. var hiddenGames = 0;
  992. $.each($("#OpenGamesTable tr"), function(key, tableRow) {
  993. if(rowIsPracticeGame(tableRow) && $(tableRow).hasClass('GameRow')) {
  994. rowSlideUp(tableRow);
  995. hiddenGames++;
  996. }
  997. //var players = $(tableRow).find("td:nth-of-type(2) span span").length;
  998. //$(tableRow).find("td:nth-of-type(2) a").append(" " + players )
  999. });
  1000. return hiddenGames;
  1001. }
  1002.  
  1003. function rowIsFFAGame(row) {
  1004. 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;
  1005. }
  1006.  
  1007. function rowIs1v1Game(row) {
  1008. return $(row).find("td:nth-of-type(2) span span").length == 2;
  1009. }
  1010.  
  1011. function rowIsTeamGame(row) {
  1012. 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;
  1013. }
  1014.  
  1015. function rowIsCustomScenarioGame(row) {
  1016. return $(row).find("[src='https://d2wcw7vp66n8b3.cloudfront.net/Images/GameInfoIcons/CustomScenario.png']").length == 1;
  1017. }
  1018.  
  1019. function rowIsPracticeGame(row) {
  1020. return $(row).find("[src='https://d2wcw7vp66n8b3.cloudfront.net/Images/GameInfoIcons/PracticeGame.png']").length == 1;
  1021. }
  1022.  
  1023. function getLuckFromRow(row) {
  1024. var luck = 0;
  1025. if($(row).find("[src='https://d2wcw7vp66n8b3.cloudfront.net/Images/GameInfoIcons/LuckModifier.png']").length == 1) {
  1026. luck = $(row).find("[src='https://d2wcw7vp66n8b3.cloudfront.net/Images/GameInfoIcons/LuckModifier.png']").attr('title').match(/^[^1-9]*(.*)%/)[1]
  1027. }
  1028. return luck;
  1029. }
  1030.  
  1031. window.applyOpenGameFilters = function() {
  1032. var hiddenGames = 0;
  1033. if (showOpenGamesFilter) {
  1034. if(openGamesFilters["hideLuck"] < 100) {
  1035. hiddenGames += hideGamesWithLuckOver(openGamesFilters["hideLuck"])
  1036. }
  1037. if(openGamesFilters["hideFFA"]) {
  1038. hiddenGames += hideFFAGames();
  1039. }
  1040.  
  1041. if(openGamesFilters["hideTeam"]) {
  1042. hiddenGames += hideTeamGames();
  1043. }
  1044.  
  1045. if(openGamesFilters["hide1v1"]) {
  1046. hiddenGames += hide1v1Games();
  1047. }
  1048. if(openGamesFilters["hideCustomScenario"]) {
  1049. hiddenGames += hideCustomScenarioGames();
  1050. }
  1051. if(openGamesFilters["hidePractice"]) {
  1052. hiddenGames += hidePracticeGames();
  1053. }
  1054. }
  1055. if(hiddenGames > 0 && $("#gamesAreHidden").length == 0) {
  1056. $("#RestoreLotteryGamesBtn").after("<span id='gamesAreHidden' style='color: gray;font-style: italic;'>Some Games are hidden</span>");
  1057. $("#gamesAreHidden").parent().parent().removeClass()
  1058. }
  1059. }
  1060.  
  1061. function rowSlideUp(row) {
  1062. $(row).remove();
  1063. }
  1064.  
  1065. function storeFilterVariables() {
  1066. openGamesFilters = {};
  1067. openGamesFilters["hideTeam"] = $("#hideTeam").prop("checked")
  1068. openGamesFilters["hideFFA"] = $("#hideFFA").prop("checked")
  1069. openGamesFilters["hide1v1"] = $("#hide1v1").prop("checked")
  1070. openGamesFilters["hideCustomScenario"] = $("#hideCustomScenario").prop("checked")
  1071. openGamesFilters["hidePractice"] = $("#hidePractice").prop("checked")
  1072.  
  1073. var luck = $("#hideLuck").val();
  1074. if($.isNumeric(luck) && luck <= 100 && luck >= 0) {
  1075. openGamesFilters["hideLuck"] = luck;
  1076. } else {
  1077. openGamesFilters["hideLuck"] = 100;
  1078. }
  1079. localStorage.setItem("openGamesFilters", JSON.stringify(openGamesFilters));
  1080. }
  1081.  
  1082. function updateFilterSettings() {
  1083. $("#hideTeam").prop("checked", openGamesFilters["hideTeam"]);
  1084. $("#hideFFA").prop("checked", openGamesFilters["hideFFA"]);
  1085. $("#hide1v1").prop("checked", openGamesFilters["hide1v1"]);
  1086. $("#hideCustomScenario").prop("checked", openGamesFilters["hideCustomScenario"]);
  1087. $("#hidePractice").prop("checked", openGamesFilters["hidePractice"]);
  1088. $("#hideLuck").val(openGamesFilters["hideLuck"] || 100);
  1089. }
  1090.  
  1091.  

QingJ © 2025

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