[GC | BETA] - Enhanced UB Search Helper

Adds enhanced search features to SW and TP to make the navigation of searching and browsing expensive items easier.

  1. // ==UserScript==
  2. // @name [GC | BETA] - Enhanced UB Search Helper
  3. // @namespace https://greatest.deepsurf.us/en/users/1225524-kaitlin
  4. // @match https://www.grundos.cafe/market/wizard/*
  5. // @match https://www.grundos.cafe/island/tradingpost/*
  6. // @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
  7. // @license MIT
  8. // @version .1
  9. // @author Cupkait
  10. // @description Adds enhanced search features to SW and TP to make the navigation of searching and browsing expensive items easier.
  11. // ==/UserScript==
  12.  
  13. const wizText = $("#page_content > main");
  14. const pageUrl = window.location.href;
  15.  
  16. //HANDLE SHOP WIZ SEARCHES
  17. if (pageUrl.includes("grundos.cafe/market/wizard/")) {
  18. const noneBuyable = wizText.find("p.center");
  19. var itemSearched = $(wizText).find('strong').eq(0).text().split('... ')[1].trim();
  20.  
  21. console.log(itemSearched);
  22.  
  23. if (noneBuyable.text().includes("I did not find anything")) {
  24. noneBuyable.html('Oh dear, no one is selling one of these... <img src="https://grundoscafe.b-cdn.net/boards/emoticons/holler.gif"><br>Try one of these locations, perhaps?<div id="altlinks"><div class="button" id="tp"><a href="https://www.grundos.cafe/island/tradingpost/browse/?query=' + itemSearched + '&autosubmit=1">trading post</a></div> <div class="button" id="ah"><a href="https://www.grundos.cafe/auctions/genie/?type=process_genie&query=' + itemSearched + '&criteria=exact">auction house</a></div></div>');
  25. console.log("Item is not available on the Shop Wizard.");
  26. } else {
  27. console.log("Shop Wizard search successfully returned results.")
  28. }
  29. };
  30.  
  31. //HANDLE TRADING POST SEARCHES
  32. if (pageUrl.includes("grundos.cafe/island/tradingpost"))
  33. {
  34. (function() {
  35. var autosubmitParam = '&autosubmit=1';
  36. $('document').ready( function() {
  37. $('a[href*="tradingpost/browse/?query"]').click(function() {
  38. const shouldSubmit = confirm("Submit trading post query?");
  39. if (shouldSubmit) {
  40. window.open($(this).attr('href') + autosubmitParam);
  41. return false;
  42. }
  43. } );
  44. const shouldAutosearch = new RegExp(`.*tradingpost\/browse.*query.*${autosubmitParam}.*`).test(window.location.href);
  45. if (shouldAutosearch) {
  46. var queryExists = $('input[name="query"]').eq(1).val().length > 0;
  47. var isNewSearch = $('.browse').length == 0
  48. if (queryExists && isNewSearch) {
  49. $('input[value="Find those lots!"]').click();
  50. }
  51. }
  52. });
  53. })();
  54. console.log("Trading Post")
  55. $('.trade-item').each(function () {
  56. var itemName = $(this).find('span').eq(0).text();
  57. console.log(itemName)
  58.  
  59. $(this).after('<div id="tplinks"><div class="tpsearch" id="tp"><a alt="Shop Wizard" href="https://www.grundos.cafe/market/wizard/?query=' + itemName + '&autosubmit=1"><i class="material-icons">store</i></a></div><div class="tpsearch" id="tp"><a alt="Trading Post" href="https://www.grundos.cafe/island/tradingpost/browse/?query='+ itemName + '&autosubmit=1"><i class="material-icons">swap_horiz</i></a></div> <div class="tpsearch" id="ah"><a alt="Auction House" href="https://www.grundos.cafe/auctions/genie/?type=process_genie&query=' + itemName + '&criteria=exact"><i class="material-icons">gavel</i></a></div><div class="tpsearch" id="tp"><a alt="Site Search" href="https://www.grundos.cafe/search/items/?item_name=' + itemName + '"><i class="material-icons">search</i></a></div></div>');
  60.  
  61.  
  62. });
  63. }
  64.  
  65.  
  66.  
  67. const style = document.createElement('style');
  68. style.innerHTML = `
  69.  
  70. @import url(https://fonts.googleapis.com/icon?family=Material+Icons);
  71. .material-icons {
  72. }
  73.  
  74. #altlinks {
  75. display:flex;
  76. justify-content:center;
  77. padding:10px;
  78. }
  79. #tplinks {
  80. display:flex;
  81. justify-content:right;
  82. padding:0px;
  83. margin:0px;
  84. }
  85. .tpsearch {
  86. padding: 0 5px 0 5px;
  87. }
  88. .big-gap {
  89. row-gap:0px !important;
  90. }
  91. .tpsearch a, .tpsearch:hover a{
  92. color:black !important;
  93. font-decoration:none;
  94. font-weight:normal;
  95. padding: 0 5px 0 5px;
  96. }
  97.  
  98. .button a, .button:hover a {
  99. font-weight:normal !important;
  100. color:black !important;}
  101.  
  102. .button {
  103. padding:5px;
  104. margin:10px;
  105. font-family:heffaklump;
  106. font-size:28px;
  107. border:1px solid black;
  108. box-shadow:5px 5px 5px #00000078;
  109. background-color:#f5f5f575;
  110. border-radius:50px;
  111. }
  112. `;
  113. document.head.appendChild(style);