Tidy up your Dashboard

Customizable Userscript which tidies up your Dashboard!

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

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

QingJ © 2025

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