[GC] Trading Post QoL

Adds links to the static lot numbers, show how many active lots you have, move autosale items to the top and change the color of the lot

  1. // ==UserScript==
  2. // @name [GC] Trading Post QoL
  3. // @namespace Masterofdarkness and hanso
  4. // @match https://www.grundos.cafe/island/tradingpost/*
  5. // @match https://grundos.cafe/island/tradingpost/*
  6. // @icon https://www.google.com/s2/favicons?sz=64&domain=grundos.cafe
  7. // @grant GM_setValue
  8. // @license MIT
  9. // @version 1.3
  10. // @author Masterofdarkness and hanso
  11. // @description Adds links to the static lot numbers, show how many active lots you have, move autosale items to the top and change the color of the lot
  12. // @downloadURL
  13. // @updateURL
  14. // ==/UserScript==
  15.  
  16. //Activate routine only if on your trade page
  17. if(window.location.href == 'https://www.grundos.cafe/island/tradingpost/') {
  18. //Move AutoSale items to the top and change color to trade lot blue
  19. const container = document.querySelector('.trading_post');
  20. let tradeLots = Array.from(container.querySelectorAll('.trade-lot'));
  21. const hrBars = Array.from(container.querySelectorAll('hr'));
  22. const pattern = /^[0-9,]+ NP$/;
  23.  
  24. let createLot = Array.from(container.querySelectorAll('.flex-column.big-gap'));
  25. let createLotButtonText = createLot[createLot.length - 1];
  26.  
  27. tradeLots = tradeLots.map(tradeLot => { return { div : tradeLot, hrBar: tradeLot.nextElementSibling.tagName === 'HR' ? tradeLot.nextElementSibling : null }});
  28. tradeLots.sort((a, b) => {
  29. const spanA = a.div.querySelector('span[id^="quicksale-text-"]');
  30. const spanB = b.div.querySelector('span[id^="quicksale-text-"]');
  31.  
  32. const matchesA = spanA && pattern.test(spanA.textContent.trim());
  33. const matchesB = spanB && pattern.test(spanB.textContent.trim());
  34.  
  35. return (matchesB ? 1 : 0) - (matchesA ? 1 : 0);
  36. });
  37.  
  38. tradeLots.forEach(tradeLot => {
  39. if(!tradeLot.div.innerHTML.includes(`<em class="gray">None</em>`)) {
  40. tradeLot.div.style.backgroundColor = '#b0bcec';
  41. }
  42. container.appendChild(tradeLot.div);
  43. if (tradeLot.hrBar) {
  44. container.appendChild(tradeLot.hrBar);
  45. }
  46.  
  47. });
  48.  
  49. container.appendChild(createLotButtonText);
  50. }
  51.  
  52. //Make static Lot#s clickable links
  53. document.querySelectorAll('div.flex-column.small-gap span > strong, div.flex.space-between > strong').forEach(strong => {const m = strong.innerHTML.match(/Lot #(\d+)/);if(m)strong.innerHTML = `<a href="https://www.grundos.cafe/island/tradingpost/lot/${m[1]}">Lot #${m[1]}</a>`});
  54.  
  55. //Get Number of active lots
  56. let i = 0;
  57. document.querySelectorAll('div.trade-lot.flex-column.big-gap').forEach(trade => {i++});
  58.  
  59. //Print value of active lots out of 20
  60. let elements = document.querySelector('strong.center.bigfont')
  61. elements.textContent += ` (${i}/20)`;
  62.  
  63.