MH: Profile+

Community requested features for the tabs on your MH profile.

当前为 2022-04-06 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name MH: Profile+
  3. // @author Warden Slayer - Warden Slayer#2010
  4. // @namespace https://greasyfork.org/en/users/227259-wardenslayer
  5. // @version 1.22
  6. // @description Community requested features for the tabs on your MH profile.
  7. // @grant GM_xmlhttpRequest
  8. // @include https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js
  9. // @include http://www.mousehuntgame.com/*
  10. // @include https://www.mousehuntgame.com/*
  11. // @connect http://www.mousehuntgame.com/*
  12. // @connect https://www.mousehuntgame.com/*
  13. // @grant GM_setClipboard
  14. // ==/UserScript==
  15. $(document).ready(function() {
  16. const debug = localStorage.getItem('ws.debug');
  17. if (debug == true) {
  18. console.log('Profile+ Started');
  19. };
  20. localStorage.setItem('ws.pfp.sortUorD','down');
  21. loadFunction();
  22. });
  23.  
  24. function loadFunction(){
  25. if ($('.mousehuntHud-page-tabHeader.kings_crowns').hasClass('active')) {
  26. //On king's crowns tab
  27. generateCrowns();
  28. } else if ($('.mousehuntHud-page-tabHeader.items').hasClass('active')) {
  29. //On item tab
  30. manageCollected();
  31. } else if ($('.mousehuntHud-page-tabHeader.profile').hasClass('active')) {
  32. //On profile tab
  33. generateProfile();
  34. } else if ($('.mousehuntHud-page-tabHeader.mice').hasClass('active')) {
  35. //On mouse Tab
  36. generateMice();
  37. } else {
  38. return false
  39. }
  40. }
  41.  
  42. $(document).ajaxComplete(function(event,xhr,options){
  43. if (options.url == 'https://www.mousehuntgame.com/managers/ajax/users/userData.php') {
  44. } else if (options.url == 'https://www.mousehuntgame.com/managers/ajax/users/userInventory.php') {
  45. } else {
  46. loadFunction();
  47. }
  48. });
  49.  
  50. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  51. //Profile TAB
  52. //
  53. //
  54. //
  55. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  56. function generateProfile() {
  57. //With the mhcc level, an egg, a checkmark, a crown, a star
  58. const debug = localStorage.getItem('ws.debug');
  59. let userID = "";
  60. const myProfileLink = $('.mousehuntHud-shield').attr('href');
  61. let maybeYourFriend = "";
  62. let eggMaster = localStorage.getItem('ws.pfp.eggMaster');
  63. if ($('.userInteractionButtonsView-relationship').get(0)) {
  64. userID = $('.userInteractionButtonsView-relationship').attr('data-recipient-snuid');
  65. maybeYourFriend = userID;
  66. } else if (myProfileLink) {
  67. if (myProfileLink.search('snuid=')==-1) {
  68. if (debug == true) {
  69. console.log('Your SNUID Not Found',myProfileLink);
  70. };
  71. return false;
  72. } else {
  73. userID = myProfileLink.split('snuid=')[1].split('&tab=')[0];
  74. }
  75. } else {
  76. if (debug == true) {
  77. console.log('SNUID Not Found',myProfileLink,userID);
  78. };
  79. return false;
  80. }
  81. localStorage.setItem('ws.pfp.eggMaster',"")
  82. const dataItemOfInterest = ['is_egg_master','not_a_real_field'];
  83. hg.utils.User.getUserData([userID],dataItemOfInterest,function(data) {
  84. eggMaster = localStorage.setItem('ws.pfp.eggMaster',data[0].is_egg_master);
  85. });
  86. setTimeout(flexEggMaster, 1000);
  87. if (debug == true) {
  88. console.log('Profile Tab',userID,eggMaster);
  89. };
  90. //stop the silly hyperlink on the hunter ID
  91. const hunterID = $('.hunterInfoView-idCardBlock-secondaryHeader').children();
  92. hunterID.removeAttr("href").removeAttr("onclick");
  93. //
  94. //tipping/misc
  95. if (maybeYourFriend) {
  96. const yourFriendsProfile = $('.friendsPage-friendRow-content');
  97. if ($('#tipButton').get(0)) {
  98. return false;
  99. } else {
  100. $('.friendsPage-friendRow-content').css({
  101. 'padding-top': '0px',
  102. });
  103. const tipButton = document.createElement("button");
  104. tipButton.id = "tipButton";
  105. $(tipButton).attr('title', 'Tip this hunter 10 SB+');
  106. $(tipButton).text('Tip 10 SB+');
  107. yourFriendsProfile.prepend(tipButton);
  108. $(tipButton).css({
  109. 'background-image': "url('https://www.toptal.com/designers/subtlepatterns/patterns/interlaced.png')",
  110. 'background-repeat': 'no-repeat',
  111. 'background-size': 'contain',
  112. 'position': 'relative',
  113. 'left': '37px',
  114. 'width': '85px',
  115. 'height': '20px',
  116. });
  117. }
  118.  
  119. } else if ($('.friendsProfileView-selfStats').get(0)) {
  120. const randomFriend = $('.friendsProfileView-randomFriend');
  121. const randoSNUID = randomFriend.attr('href').split('snuid=')[1].split('&tab=')[0];
  122. hg.utils.User.getUserData([randoSNUID],['not_a_real_field'],function(data) {
  123. randomFriend.text('Visit Random Friend ('+data[0].name+')');
  124. });
  125. }
  126. }
  127.  
  128. function flexEggMaster() {
  129. const eggMaster = localStorage.getItem('ws.pfp.eggMaster');
  130. if (eggMaster == 'true') {
  131. if ($(".eggMasterIcon").length > 0) return;
  132. const hunterID = $('.friendsPage-friendRow-titleBar');
  133. const eggMasterIcon = document.createElement("div");
  134. eggMasterIcon.classList.add("eggMasterIcon");
  135. $(eggMasterIcon).attr('title', 'Is an Egg Master')
  136. $(eggMasterIcon).css({
  137. 'background-size': '25px 25px',
  138. 'background-image': "url('https://i.ibb.co/qj01CGk/image-removebg-preview-35.png')",
  139. 'width': '25px',
  140. 'height': '25px',
  141. 'float': 'right',
  142. 'margin-right': '7px',
  143. });
  144. hunterID.append(eggMasterIcon)
  145. }
  146. }
  147.  
  148. $(document).on('click', '#tipButton', function() {
  149. const debug = localStorage.getItem('ws.debug');
  150. const receivingHunter = $('.userInteractionButtonsView-relationship').attr('data-recipient-snuid');
  151. const receivingName = $('.friendsPage-friendRow-titleBar-name').attr('data-text');
  152. const sendingHunter = user.unique_hash;
  153. const url = 'https://www.mousehuntgame.com/managers/ajax/users/supplytransfer.php?/sn=Hitgrab&hg_is_ajax=1&receiver='+receivingHunter+'&uh='+sendingHunter+'&item=super_brie_cheese&item_quantity=10';
  154. GM_xmlhttpRequest({
  155. method: "POST",
  156. url: url,
  157. onload: function(response) {
  158. if (debug == true) {
  159. console.log('Tip Sent',receivingName,receivingHunter);
  160. }
  161. alert('10 SB+ sent to '+receivingName);
  162. },
  163. onerror: function(response) {
  164. if (debug == true) {
  165. console.log('Tip No Good, Error',receivingName,receivingHunter,url);
  166. }
  167. alert('Error, nothing sent');
  168. }
  169. });
  170. })
  171.  
  172. $(document).on('click', '.hunterInfoView-idCardBlock-secondaryHeader', function() {
  173. const debug = localStorage.getItem('ws.debug');
  174. const copiedID = $('.hunterInfoView-hunterId').find('span').text();
  175. if (debug == true) {
  176. console.log('ID Copied',copiedID)
  177. };
  178. GM_setClipboard(copiedID);
  179. })
  180.  
  181. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  182. //Mouse TAB
  183. //
  184. //
  185. //
  186. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  187. function generateMice() {
  188. const debug = localStorage.getItem('ws.debug');
  189. const allMice = $('.mouseListView-categoryContent-subgroup-mouse.stats:not(.header)');
  190. const statsHeader = $('.mouseListView-categoryContent-subgroup-mouse.stats.header');
  191. allMice.each(function(i) {
  192. const thisThumb = $(this).find('.mouseListView-categoryContent-subgroup-mouse-thumb');
  193. const thisCatches = parseInt($(this).find('.catches').text().replace(",", ""),10);
  194. const thisMisses = parseInt($(this).find('.misses').text().replace(",", ""),10);
  195. setCrownBorder(thisThumb,thisCatches);
  196. });
  197. $(statsHeader).css({
  198. 'cursor': 'pointer',
  199. });
  200. $('.mouseListView-categoryContent-subgroup-mouse.stats.header').on('click', '.mouseListView-categoryContent-subgroup-mouse-stats', function() {
  201. SortMice(this);
  202. })
  203. }
  204.  
  205. function SortMice(sortBy) {
  206. const sortUorD = localStorage.getItem('ws.pfp.sortUorD');
  207. let sortKey = "";
  208. if ($(sortBy).hasClass('name')) {
  209. sortKey = '.name';
  210. } else if ($(sortBy).hasClass('catches')) {
  211. sortKey = '.catches';
  212. } else if ($(sortBy).hasClass('misses')) {
  213. sortKey = '.misses';
  214. } else if ($(sortBy).hasClass('average_weight')) {
  215. sortKey = '.average_weight';
  216. } else if ($(sortBy).hasClass('heaviest_catch')) {
  217. sortKey = '.heaviest_catch';
  218. }
  219. if (sortUorD == 'up') {
  220. sortMiceBy(sortKey,'down');
  221. localStorage.setItem('ws.pfp.sortUorD','down');
  222. } else {
  223. sortMiceBy(sortKey,'up');
  224. localStorage.setItem('ws.pfp.sortUorD','up');
  225. }
  226. }
  227.  
  228. function setCrownBorder(thumb,catches) {
  229. let top = "";
  230. let bottom = "";
  231. if ((catches >= 10) && (catches < 100)) {
  232. top = '#f0c693';
  233. bottom = '#8d4823';
  234. } else if ((catches >= 100) && (catches < 500)) {
  235. top = '#d1d7e9';
  236. bottom = '#66718b';
  237. } else if ((catches >= 500) && (catches < 1000)) {
  238. top = '#ffe589';
  239. bottom = '#b67800';
  240. } else if ((catches >= 1000) && (catches < 2500)) {
  241. top = '#9191ff';
  242. bottom = '#1d1781';
  243. } else if (catches >= 2500) {
  244. top = '#c4eae6';
  245. bottom = '#63b9cf';
  246. } else {
  247. //no crown
  248. top = '#ab9f92';
  249. bottom = '#251B0A';
  250. }
  251. $(thumb).css({
  252. 'border-style': 'solid',
  253. 'border-width': '4px',
  254. 'border-radius': '4px',
  255. 'border-top-color': top,
  256. 'border-left-color': top,
  257. 'border-bottom-color': bottom,
  258. 'border-right-color': bottom,
  259. });
  260. }
  261.  
  262. function sortMiceBy(key,UD) {
  263. let activeGrouping = $('.mousehuntHud-page-subTabContent.active[data-template-file="AdversariesPage"]');
  264. let activeSubGroup = "";
  265. if ($('.mouseListView-categoryContent-category.active.hasFilter.caught').length > 0) {
  266. activeSubGroup = $(activeGrouping).find('.mouseListView-categoryContent-category.active.hasFilter.caught');
  267. } else if ($('.mouseListView-categoryContent-category.active.hasFilter.uncaught').length > 0) {
  268. activeSubGroup = $(activeGrouping).find('.mouseListView-categoryContent-category.active.hasFilter.uncaught');
  269. } else {
  270. activeSubGroup = $(activeGrouping).find('.mouseListView-categoryContent-category.all.active');
  271. }
  272. const mouseContainer = $(activeSubGroup).find('.mouseListView-categoryContent-subgroupContainer');
  273. const allMice = $(activeSubGroup).find('.mouseListView-categoryContent-subgroup-mouse.stats:not(.header)');
  274. $(allMice).sort(function(a, b,) {
  275. if (key == '.name') {
  276. a = $(a).find(key).text();
  277. b = $(b).find(key).text();
  278. } else if ((key == '.catches') || (key == '.misses')) {
  279. a = parseInt($(a).find(key).text(),10);
  280. b = parseInt($(b).find(key).text(),10);
  281. } else if ((key == '.average_weight') || (key == '.heaviest_catch')) {
  282. a = parseUntits($(a).find(key).text());
  283. b = parseUntits($(b).find(key).text());
  284. }
  285. if ((UD == 'up') && (a > b)) {
  286. return -1;
  287. } else if ((UD == 'up') && (a < b)) {
  288. return 1;
  289. } else if ((UD == 'down') && (a < b)) {
  290. return -1;
  291. } else if ((UD == 'down') && (a > b)) {
  292. return 1;
  293. }
  294. }).appendTo(mouseContainer);
  295. }
  296.  
  297. function parseUntits(unitString) {
  298. let oz = 0;
  299. const rawNumArray = unitString.replace(' lb. ',",").replace(' oz.',"").split(',');
  300. if (rawNumArray.length == 1) {
  301. oz = parseInt(rawNumArray[0],10);
  302. } else {
  303. oz = 16*parseInt(rawNumArray[0],10)+parseInt(rawNumArray[1],10);
  304. }
  305. return oz
  306. }
  307.  
  308.  
  309. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  310. //Crowns TAB
  311. //
  312. //
  313. //
  314. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  315. function generateCrowns() {
  316. const debug = localStorage.getItem('ws.debug');
  317. if (debug == true) {
  318. console.log('Crowns Tab',localStorage.getItem("Lock Favorites"),localStorage.getItem("ShowCommunityRanks"));
  319. };
  320. buildToolbar();
  321. decorate();
  322. if (localStorage.getItem("Lock Favorites") == "Y" && $(".mouseCrownsView-group-mouse-favouriteButton").length > 0) {
  323. lockFavorites();
  324. }
  325. if (localStorage.getItem("ShowCommunityRanks") == "Y") {
  326. localStorage.setItem('ws.mh.pfp.numMice',"");
  327. hg.utils.MouseUtil.getMouseNames(function (data) {
  328. const numMice = Object.keys($(data)[0]).length-2;
  329. localStorage.setItem('ws.mh.pfp.numMice',numMice);
  330. if (debug == true) {
  331. console.log('Total Mice',numMice);
  332. };
  333. })
  334. setTimeout(showCommunityRanks, 1000)
  335. }
  336. }
  337.  
  338. function buildToolbar() {
  339. if ($(".toolBar").length > 0) return;
  340. const toolBar = document.createElement("div");
  341. toolBar.classList.add("toolBar");
  342.  
  343. // Lock Favs CB
  344. const lockFavs = document.createElement("input");
  345. lockFavs.type = "checkbox";
  346. lockFavs.name = "lockFavs";
  347. lockFavs.value = "";
  348. lockFavs.id = "lockFavs";
  349. if (localStorage.getItem("LockFavs") == "Y") {
  350. lockFavs.checked = "Yes";
  351. } else {
  352. lockFavs.checked = "";
  353. }
  354.  
  355. const lockFavsLabel = document.createElement("label");
  356. lockFavsLabel.htmlFor = "lockFavsLabel";
  357. lockFavsLabel.appendChild(document.createTextNode("Lock Favorites"));
  358. if ($(".mouseCrownsView-group-mouse-favouriteButton").length > 0) {
  359. toolBar.appendChild(lockFavs);
  360. toolBar.appendChild(lockFavsLabel);
  361. }
  362. // Community Ranks CB
  363. const communityRanks = document.createElement("input");
  364. communityRanks.type = "checkbox";
  365. communityRanks.name = "communityRanks";
  366. communityRanks.value = "";
  367. communityRanks.id = "communityRanks";
  368. communityRanks.checked = "";
  369. if (localStorage.getItem("ShowCommunityRanks") == "Y") {
  370. communityRanks.checked = "Yes";
  371. } else {
  372. communityRanks.checked = "";
  373. }
  374.  
  375. const communityRanksLabel = document.createElement("label");
  376. communityRanksLabel.htmlFor = "communityRanksLabel";
  377. communityRanksLabel.appendChild(
  378. document.createTextNode("Show King's Crown Summary ")
  379. );
  380. toolBar.appendChild(communityRanks);
  381. toolBar.appendChild(communityRanksLabel);
  382.  
  383. //Copy Crown Button
  384. const copyCrownsButton = document.createElement("button");
  385. copyCrownsButton.id = "copyCrownsButton";
  386. if ($(".mouseCrownsView-group-mouse-favouriteButton").length > 0) {
  387. copyCrownsButton.addEventListener("click", copyMyCrowns)
  388. } else {
  389. copyCrownsButton.addEventListener("click", copyCrowns)
  390. }
  391. $(copyCrownsButton).attr('title', 'Copy Crowns to Clipboard');
  392. toolBar.appendChild(copyCrownsButton);
  393. $(copyCrownsButton).css({
  394. 'background-image': "url('https://cdn3.iconfinder.com/data/icons/files-folders-line/100/copy-512.png')",
  395. 'background-repeat': 'no-repeat',
  396. 'background-size': 'contain',
  397. 'width': '25px',
  398. 'height': '25px',
  399. });
  400. // Last
  401. let crownBreak = $('.mouseCrownsView-group.favourite');
  402. crownBreak.append(toolBar);
  403. $(".toolBar").css({
  404. 'float': "right",
  405. });
  406. }
  407.  
  408. /********** Lock Favs **********/
  409. $(document).on("change", "#lockFavs", function() {
  410. if (
  411. window.location.href.includes("profile.php") &&
  412. $(".mousehuntHud-page-tabHeader.kings_crowns").hasClass("active")
  413. ) {
  414. // Check to see if the cb was JUST checked
  415. if (this.checked) {
  416. // Put the checked value into storage
  417. localStorage.setItem("LockFavs", "Y");
  418. lockFavs.checked = "Yes";
  419. lockFavorites();
  420. } else {
  421. // Put the checked value into storage
  422. localStorage.setItem("LockFavs", "N");
  423. lockFavs.checked = "";
  424. unlockFavorites();
  425. }
  426. }
  427. });
  428.  
  429. function lockFavorites() {
  430. localStorage.setItem("Lock Favorites", "Y");
  431. if ($(".mouseCrownsView-group-mouse-favouriteButton").length < 0) {
  432. localStorage.setItem("LockFavs", "N");
  433. lockFavs.checked = "";
  434. return;
  435. }
  436. const allMice = $(".mouseCrownsView-group-mouse").find('.mouseCrownsView-group-mouse-favouriteButton');
  437. allMice.css("pointer-events", "none");
  438. $(".mouseCrownsView-crown.favourite").css(
  439. "background",
  440. "url('https://image.flaticon.com/icons/svg/204/204310.svg') no-repeat left top"
  441. );
  442. }
  443.  
  444. function unlockFavorites() {
  445. localStorage.setItem("Lock Favorites", "N");
  446. const allMice = $(".mouseCrownsView-group-mouse").find('.mouseCrownsView-group-mouse-favouriteButton');
  447. allMice.css("pointer-events", "auto");
  448. $(".mouseCrownsView-crown.favourite").css({
  449. 'background-image': "url('https://www.mousehuntgame.com/images/ui/camp/trap/star_favorite.png')",
  450. 'display': 'inline-block',
  451. 'vertical-align': 'middle',
  452. 'width': '50px',
  453. 'height': '50px',
  454. 'margin-right': '5px',
  455. 'background-repeat': 'no-repeat',
  456. 'background-position': '50% 50%',
  457. 'background-size': 'contain'
  458. });
  459. }
  460.  
  461. /********** Community Ranks **********/
  462. $(document).on("change", "#communityRanks", function() {
  463. if (
  464. window.location.href.includes("profile.php") &&
  465. $(".mousehuntHud-page-tabHeader.kings_crowns").hasClass("active")
  466. ) {
  467. // Check to see if the cb was JUST checked
  468. if (this.checked) {
  469. // Put the checked value into storage
  470. localStorage.setItem("ShowCommunityRanks", "Y");
  471. communityRanks.checked = "Yes";
  472. showCommunityRanks();
  473. } else {
  474. // Put the checked value into storage
  475. localStorage.setItem("ShowCommunityRanks", "N");
  476. communityRanks.checked = "";
  477. hideCommunityRanks();
  478. }
  479. }
  480. });
  481.  
  482. function showCommunityRanks() {
  483. const debug = localStorage.getItem('ws.debug');
  484. const totalMice = localStorage.getItem('ws.mh.pfp.numMice');
  485. if ($(".crownheader.crownheadercommunity").length > 0) {
  486. return;
  487. }
  488. const crownBreak = $(".mouseCrownsView-group.favourite");
  489. const communityCrownHeader = $(
  490. "<div class='crownheader crownheadercommunity'>King's Crown Summary</div>"
  491. );
  492. communityCrownHeader.css({
  493. 'background-image': "url('https://icon-library.com/images/138339.png')",
  494. 'background-repeat': 'no-repeat',
  495. 'background-size': '25px 25px',
  496. });
  497. communityCrownHeader.insertAfter(crownBreak);
  498. const allUncrowned = $(".mouseCrownsView-group.none").find(".mouseCrownsView-group-mouse");
  499. const allBronze = $(".mouseCrownsView-group.bronze,.mouseCrownsView-group.silver,.mouseCrownsView-group.gold,.mouseCrownsView-group.platinum,.mouseCrownsView-group.diamond").find(".mouseCrownsView-group-mouse");
  500. const allSilver = $(".mouseCrownsView-group.silver,.mouseCrownsView-group.gold,.mouseCrownsView-group.platinum,.mouseCrownsView-group.diamond").find(".mouseCrownsView-group-mouse");
  501. const allGold = $(".mouseCrownsView-group.gold,.mouseCrownsView-group.platinum,.mouseCrownsView-group.diamond").find(".mouseCrownsView-group-mouse");
  502. const allPlat = $(".mouseCrownsView-group.platinum,.mouseCrownsView-group.diamond").find(".mouseCrownsView-group-mouse");
  503. const allDiamond = $(".mouseCrownsView-group.diamond").find(".mouseCrownsView-group-mouse");
  504. const bronzeCrowns = allBronze.length;
  505. const silverCrowns = allSilver.length;
  506. const goldCrowns = allGold.length;
  507. const platCrowns = allPlat.length;
  508. const diamondCrowns = allDiamond.length;
  509. const uncrowned = totalMice - bronzeCrowns;
  510. if (debug == true) {
  511. console.log('Crown Counts',uncrowned,bronzeCrowns,silverCrowns,goldCrowns,platCrowns,diamondCrowns);
  512. };
  513. const bronzeLink = "https://docs.google.com/spreadsheets/d/19_wHCkwiT5M6LS7XNLt4NYny98fjpg4UlHbgOD05ijw/pub?fbclid=IwAR3a1Ku2xTl1mIDksUr8Lk5ORMEnuv7jnvIy9K6OBeziG6AyvYYlZaIQkHY"
  514. const silverLink = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vQG5g3vp-q7LRYug-yZR3tSwQzAdN7qaYFzhlZYeA32vLtq1mJcq7qhH80planwei99JtLRFAhJuTZn/pubhtml?fbclid=IwAR3sPXNLloGnFk324a0HShroP1E-sNcnQBlRTjJ7gScWTWosqmXv5InB_Ns'
  515. const goldLink = 'https://docs.google.com/spreadsheets/d/10OGD5OYkGIEAbiez7v92qU5Fdul0ZtCRgEjlECkwZJE/pubhtml?gid=478731024&single=true&fbclid=IwAR28w7IQyMp91I62CR3GOILpbeLwgKaydIoQimMNm7j3S0DL8Mj_IsRpGD4'
  516. const rankSummary = $("<div class='rank summary'</div>");
  517. rankSummary.css({
  518. 'font-size': '12px',
  519. 'margin-bottom': '10px',
  520. });
  521. rankSummary.insertAfter(communityCrownHeader);
  522. const uncrownedText = document.createTextNode("Uncrowned: " + uncrowned + " (" + ((uncrowned / totalMice) * 100).toFixed(2) + "%) | ");
  523. $(rankSummary).attr('title', 'Mobster and Leprechaun excluded from counts');
  524. const bronzeText = document.createTextNode("Bronze: " + bronzeCrowns + " (" + ((bronzeCrowns / totalMice) * 100).toFixed(2) + "%) | ");
  525. const silverText = document.createTextNode("Silver: " + silverCrowns + " (" + ((silverCrowns / totalMice) * 100).toFixed(2) + "%) | ");
  526. const goldText = document.createTextNode("Gold: " + goldCrowns + " (" + ((goldCrowns / totalMice) * 100).toFixed(2) + "%) | ");
  527. const platText = document.createTextNode("Platinum: " + platCrowns + " (" + ((platCrowns / totalMice) * 100).toFixed(2) + "%) | ");
  528. const diamondText = document.createTextNode("Diamond: " + diamondCrowns + " (" + ((diamondCrowns / totalMice) * 100).toFixed(2) + "%)");
  529. const aBronze = document.createElement('a');
  530. aBronze.appendChild(bronzeText);
  531. //const bronzeRank = getRankBronze(allBronze.length)
  532. //aBronze.title = "90% Crowned Scoreboard: " + bronzeRank;
  533. aBronze.title = "90% Crowned Scoreboard";
  534. aBronze.href = bronzeLink;
  535. $(aBronze).attr("target", "_blank");
  536. const aSilver = document.createElement('a');
  537. aSilver.appendChild(silverText);
  538. //const silverRank = getRankSilver(allSilver.length)
  539. //aSilver.title = "MHCC Scoreboard: " + silverRank;
  540. aSilver.title = "MHCC Scoreboard";
  541. aSilver.href = silverLink;
  542. $(aSilver).attr("target", "_blank");
  543. const aGold = document.createElement('a');
  544. aGold.appendChild(goldText);
  545. aGold.title = "MHCC Elite Scoreboard";
  546. aGold.href = goldLink;
  547. $(aGold).attr("target", "_blank");
  548. $(rankSummary).append(uncrownedText).append(aBronze).append(aSilver).append(aGold).append(platText).append(diamondText);
  549. }
  550.  
  551. function getRankBronze(crowns) {
  552. const totalMice = localStorage.getItem('ws.mh.pfp.numMice');
  553. let rank = "";
  554. if (crowns >= totalMice) {
  555. rank = "Hepatizon";
  556. } else if (crowns >= 1057) {
  557. rank = "Electrum";
  558. } else if (crowns >= 1046) {
  559. rank = "Palladium";
  560. } else if (crowns >= 1014) {
  561. rank = "Cobalt";
  562. } else if (crowns >= 961) {
  563. rank = "Bronze (full)";
  564. } else if (crowns >= 907) {
  565. rank = "Titanium";
  566. } else if (crowns >= 854) {
  567. rank = "Pewter";
  568. } else if (crowns >= 801) {
  569. rank = "Brass";
  570. } else if (crowns >= 747) {
  571. rank = "Copper";
  572. } else if (crowns >= 694) {
  573. rank = "Tin";
  574. } else {
  575. rank = "Rust";
  576. }
  577.  
  578. return rank;
  579. }
  580.  
  581. function getRankSilver(crowns) {
  582. const totalMice = localStorage.getItem('ws.mh.pfp.numMice');
  583. let rank = "";
  584. if (crowns >= 960) {
  585. rank = "Super Secret Squirrel";
  586. } else if (crowns >= 906) {
  587. rank = "Grizzled Squirrel";
  588. } else if (crowns >= 853) {
  589. rank = "Flying Squirrel";
  590. } else if (crowns >= 800) {
  591. rank = "Chinchilla";
  592. } else if (crowns >= 746) {
  593. rank = "Meerkat";
  594. } else if (crowns >= 693) {
  595. rank = "Ferret";
  596. } else if (crowns >= 640) {
  597. rank = "Prairie Dog";
  598. } else if (crowns >= 586) {
  599. rank = "Marmot";
  600. } else if (crowns >= 533) {
  601. rank = "Woodchuck";
  602. } else if (crowns >= 480) {
  603. rank = "Wombat";
  604. } else if (crowns >= 426) {
  605. rank = "Pine Marten";
  606. } else if (crowns >= 373) {
  607. rank = "Chipmunk";
  608. } else if (crowns >= 320) {
  609. rank = "Bandicoot";
  610. } else {
  611. rank = "Weasel";
  612. }
  613. return rank;
  614. }
  615.  
  616. function hideCommunityRanks() {
  617. if ($(".crownheader.crownheadercommunity").length > 0) {
  618. $(".crownheader.crownheadercommunity").remove();
  619. $(".rank.summary").remove();
  620. }
  621. }
  622.  
  623. function copyMyCrowns() {
  624. const debug = localStorage.getItem('ws.debug');
  625. hg.utils.MouseUtil.getHuntingStats(function(data) {
  626. let statArray = [];
  627. data.forEach(function(arrayItem, index) {
  628. const mouseName = correctMouseName(arrayItem.name);
  629. const catches = arrayItem.num_catches;
  630. const misses = arrayItem.num_misses;
  631. statArray[index] = [mouseName, catches, misses];
  632. })
  633. if (debug == true) {
  634. console.log('My Mice Array',statArray);
  635. };
  636. let finalTable = statArray.map(e => e.join(",")).join("\n");
  637. GM_setClipboard(finalTable);
  638. const copyCrownsButton = $("#copyCrownsButton")
  639. copyCrownsButton.css({
  640. 'border-style': 'solid',
  641. 'border-color': 'grey',
  642. 'border-width': '1px',
  643. });
  644. setTimeout(function() {
  645. copyCrownsButton.css({
  646. 'border-style': 'none',
  647. });
  648. }, 1000);
  649. })
  650. }
  651.  
  652.  
  653. function copyCrowns() {
  654. const debug = localStorage.getItem('ws.debug');
  655. const allMice = $(".mouseCrownsView-group.none,.mouseCrownsView-group.bronze,.mouseCrownsView-group.silver,.mouseCrownsView-group.gold,.mouseCrownsView-group.platinum,.mouseCrownsView-group.diamond").find(".mouseCrownsView-group-mouse");
  656. let miceArray = [];
  657. allMice.each(function(i) {
  658. let $mouse = correctMouseName($(this).find('.mouseCrownsView-group-mouse-name').text());
  659. let $count = parseInt($(this).find('.mouseCrownsView-group-mouse-catches').text().replace(',', ""), 10);
  660. miceArray[i] = [$mouse, $count];
  661. })
  662. // need to sort uncrowned by # instead of Alpha
  663. if (debug == true) {
  664. console.log('Their Mice Array',miceArray);
  665. };
  666. let finalTable = miceArray.map(e => e.join(",")).join("\n");
  667. GM_setClipboard(finalTable);
  668. const copyCrownsButton = $("#copyCrownsButton")
  669. copyCrownsButton.css({
  670. 'border-style': 'solid',
  671. 'border-color': 'grey',
  672. 'border-width': '1px',
  673. });
  674. setTimeout(function() {
  675. copyCrownsButton.css({
  676. 'border-style': 'none',
  677. });
  678. }, 1000);
  679. }
  680.  
  681. function correctMouseName(mouseName) {
  682. mouseName = mouseName.replace(" Mouse", "");
  683. let newMouseName = "";
  684. if (mouseName == "Ful'Mina, The Mountain Queen") {
  685. newMouseName = "Ful'mina the Mountain Queen";
  686. } else if (mouseName == "Inferna, The Engulfed") {
  687. newMouseName = "Inferna the Engulfed";
  688. } else if (mouseName == "Nachous, The Molten") {
  689. newMouseName = "Nachous the Molten";
  690. } else if (mouseName == "Stormsurge, the Vile Tempest") {
  691. newMouseName = "Stormsurge the Vile Tempest";
  692. } else if (mouseName == "Bruticus, the Blazing") {
  693. newMouseName = "Bruticus the Blazing";
  694. } else if (mouseName == "Vincent, The Magnificent") {
  695. newMouseName = "Vincent The Magnificent";
  696. } else if (mouseName == "Corky, the Collector") {
  697. newMouseName = "Corky the Collector";
  698. } else if (mouseName == "Ol' King Coal") {
  699. newMouseName = "Ol King Coal";
  700. } else if (mouseName == "Dread Piratert") {
  701. newMouseName = "Dread Pirate Mousert";
  702. } else {
  703. newMouseName = mouseName;
  704. }
  705. return newMouseName;
  706. }
  707.  
  708. function decorate() {
  709. let uncrowned = $('.mouseCrownsView-group.none').find('.mouseCrownsView-crown.none');
  710. $(uncrowned).css({
  711. 'background-image': "url('https://image.flaticon.com/icons/png/512/1604/1604467.png')",
  712. 'background-repeat': 'no-repeat',
  713. 'background-size': 'contain'
  714. });
  715. let favorites = $('.mouseCrownsView-group-mouse');
  716. $(favorites).each(function(i) {
  717. const image = $(this).find('.mouseCrownsView-group-mouse-image');
  718. const catches = parseInt($(this).find('.mouseCrownsView-group-mouse-catches').text().replace(",", ""),10);
  719. setCrownBorder(image,catches);
  720. });
  721. }
  722. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  723. //ITEMS TAB
  724. //
  725. //
  726. //
  727. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  728. function manageCollected() {
  729. let itemContainer = $('.hunterProfileItemsView-content-padding');
  730. //Hide LE Layout
  731. if ($('.hideLeContainer').length == 0) {
  732. let hideLeContainer = document.createElement("div");
  733. hideLeContainer.classList.add("hideLeContainer");
  734. let hideLeCb = document.createElement("input");
  735. hideLeCb.type = "checkbox";
  736. hideLeCb.name = "hideLeCb";
  737. hideLeCb.value = "";
  738. hideLeCb.id = "hideLeCb";
  739. hideLeCb.checked = "";
  740. if (localStorage.getItem("hideLeItems") == "Y") {
  741. hideLeCb.checked = "Yes";
  742. } else {
  743. hideLeCb.checked = "";
  744. }
  745. let hideLeLabel = document.createElement("label");
  746. hideLeLabel.htmlFor = "hideLeLabel";
  747. hideLeLabel.appendChild(document.createTextNode("Hide LE Items"));
  748. hideLeContainer.append(hideLeCb);
  749. hideLeContainer.append(hideLeLabel);
  750. $(itemContainer).prepend(hideLeContainer);
  751. $(hideLeContainer).css({
  752. 'width': '100%',
  753. });
  754. $(hideLeLabel).css({
  755. 'fontSize': "14px",
  756. 'width': '80%',
  757. });
  758. $(hideLeCb).css({
  759. 'width': '5%'
  760. });
  761. }
  762. if (localStorage.getItem("hideLeItems") == "Y") {
  763. hideLeItems()
  764. }
  765. let allTypes = $('.hunterProfileItemsView-categoryContent');
  766. let allItems = $(allTypes).children();
  767. allItems.click(function() {
  768. hg.views.ItemView.show($(this).attr('data-type'))
  769. });
  770. }
  771.  
  772. function hideLeItems() {
  773. let allTypes = $('.hunterProfileItemsView-categoryContent.active');
  774. let allCollected = $(allTypes).find('.hunterProfileItemsView-categoryContent-item.collected').not('.limited_edition');
  775. let allUncollected = $(allTypes).find('.hunterProfileItemsView-categoryContent-item.uncollected');
  776. let collectedLe = $(allTypes).find('.hunterProfileItemsView-categoryContent-item.collected.limited_edition');
  777. let activeTab = $('.hunterProfileItemsView-filter').filter('.active');
  778. if ($(activeTab).hasClass('collected')) {
  779. $(allCollected).show();
  780. $(allUncollected).hide();
  781. $(collectedLe).hide();
  782. } else if ($(activeTab).hasClass('uncollected')) {
  783. $(allCollected).hide();
  784. $(allUncollected).show();
  785. $(collectedLe).hide();
  786. } else if ($(activeTab).hasClass('limited_edition')) {
  787. $(allCollected).hide();
  788. $(allUncollected).hide();
  789. $(collectedLe).show();
  790. } else if ($(activeTab).hasClass('all')) {
  791. $(allCollected).show();
  792. $(allUncollected).show();
  793. $(collectedLe).hide();
  794. }
  795. }
  796.  
  797. function showLeItems() {
  798. let allTypes = $('.hunterProfileItemsView-categoryContent.active');
  799. let allCollected = $(allTypes).find('.hunterProfileItemsView-categoryContent-item.collected').not('.limited_edition');
  800. let allUncollected = $(allTypes).find('.hunterProfileItemsView-categoryContent-item.uncollected');
  801. let collectedLe = $(allTypes).find('.hunterProfileItemsView-categoryContent-item.collected.limited_edition');
  802. let activeTab = $('.hunterProfileItemsView-filter').filter('.active');
  803. if ($(activeTab).hasClass('collected')) {
  804. $(allCollected).show();
  805. $(allUncollected).hide();
  806. $(collectedLe).show();
  807. } else if ($(activeTab).hasClass('uncollected')) {
  808. $(allCollected).hide();
  809. $(allUncollected).show();
  810. $(collectedLe).hide();
  811. } else if ($(activeTab).hasClass('limited_edition')) {
  812. $(allCollected).hide();
  813. $(allUncollected).hide();
  814. $(collectedLe).show();
  815. } else if ($(activeTab).hasClass('all')) {
  816. $(allCollected).show();
  817. $(allUncollected).show();
  818. $(collectedLe).show();
  819. }
  820. }
  821.  
  822.  
  823. //Weapons Tab
  824. $(document).on('click', "[data-category='weapon']", function() {
  825. if (localStorage.getItem("hideLeItems") == "Y") {
  826. hideLeItems()
  827. } else {
  828. showLeItems();
  829. }
  830. });
  831. //Bases Tab
  832. $(document).on('click', "[data-category='base']", function() {
  833. if (localStorage.getItem("hideLeItems") == "Y") {
  834. hideLeItems()
  835. } else {
  836. showLeItems();
  837. }
  838. });
  839. //Maps Tab
  840. $(document).on('click', "[data-category='map_piece']", function() {
  841. if (localStorage.getItem("hideLeItems") == "Y") {
  842. hideLeItems()
  843. } else {
  844. showLeItems();
  845. }
  846. });
  847. //Collectible Tab
  848. $(document).on('click', "[data-category='collectible']", function() {
  849. if (localStorage.getItem("hideLeItems") == "Y") {
  850. hideLeItems()
  851. } else {
  852. showLeItems();
  853. }
  854. });
  855. //Skin Tab
  856. $(document).on('click', "[data-category='skin']", function() {
  857. if (localStorage.getItem("hideLeItems") == "Y") {
  858. hideLeItems()
  859. } else {
  860. showLeItems();
  861. }
  862. });
  863. //Collected tab
  864. $(document).on('click', ".hunterProfileItemsView-filter.collected", function() {
  865. if (localStorage.getItem("hideLeItems") == "Y") {
  866. hideLeItems()
  867. } else {
  868. showLeItems();
  869. }
  870. });
  871. //Uncollected tab
  872. $(document).on('click', ".hunterProfileItemsView-filter.uncollected", function() {
  873. if (localStorage.getItem("hideLeItems") == "Y") {
  874. hideLeItems()
  875. } else {
  876. showLeItems();
  877. }
  878. });
  879. //Limited Edition Tab
  880. $(document).on('click', ".hunterProfileItemsView-filter.limited_edition", function() {
  881. if (localStorage.getItem("hideLeItems") == "Y") {
  882. hideLeItems()
  883. } else {
  884. showLeItems();
  885. }
  886. });
  887. //All Tab
  888. $(document).on('click', ".hunterProfileItemsView-filter.all", function() {
  889. if (localStorage.getItem("hideLeItems") == "Y") {
  890. hideLeItems()
  891. } else {
  892. showLeItems();
  893. }
  894. });
  895.  
  896. /********** Layout Opt-In **********/
  897. $(document).on("change", "#hideLeCb", function() {
  898. // Check to see if the cb was JUST checked
  899. if (this.checked) {
  900. // Put the checked value into storage
  901. localStorage.setItem("hideLeItems", "Y");
  902. this.checked = "Yes";
  903. manageCollected();
  904. } else {
  905. // Put the checked value into storage
  906. localStorage.setItem("hideLeItems", "N");
  907. this.checked = "";
  908. showLeItems();
  909. }
  910. });