MouseHunt - Display Converted Charms Thumbnail

Adds a thumbnail showing the charms obtained from Unstable/Torch/Treasure Trawling Charms.

  1. // ==UserScript==
  2. // @name MouseHunt - Display Converted Charms Thumbnail
  3. // @author Jia Hao (Limerence#0448 @Discord)
  4. // @namespace https://greasyfork.org/en/users/165918-jia-hao
  5. // @version 1.3
  6. // @description Adds a thumbnail showing the charms obtained from Unstable/Torch/Treasure Trawling Charms.
  7. // @include https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js
  8. // @include http://www.mousehuntgame.com/*
  9. // @include https://www.mousehuntgame.com/*
  10. // ==/UserScript==
  11.  
  12. //Special thanks to Tan Y.K. for refactoring this function! :D
  13. function unstableThumbnails() {
  14. var charmPops = $(".chesla_trap_trigger,.torch_charm_event").not(".minimalJournal,:has(img)");
  15. charmPops.each(function() {
  16. //Only entries made by Unstable/Torch/Treasure Trawling charms
  17. if ($(this).text().indexOf("Unstable Charm") >= 0 || $(this).text().indexOf("Treasure Trawling Charm") >= 0 || $(this).text().indexOf("Torch Charm") >= 0) {
  18. var itemType = $(".journaltext>a",this).attr("href").match(/[?&]item_type=([^&]+)/);
  19. if (itemType) {
  20. var $this = $(this).prepend("<div class=journalimage><img /></div>");
  21. hg.utils.UserInventory.getItem(decodeURIComponent(itemType[1]), function(x) {
  22. $("img",$this).css("border","1px solid black").attr("src", x.thumbnail);
  23. $this.css("background-image","none");
  24. });
  25. }
  26. }
  27. });
  28. }
  29.  
  30. $(document).ajaxSuccess(unstableThumbnails);
  31. $(document).ready(function() {
  32. //If current page is main camp or journal
  33. var pageTitle = document.title;
  34. if (pageTitle.includes("Hunter's Camp") || pageTitle.includes("Journal Page")) {
  35. unstableThumbnails();
  36. }
  37.  
  38. });