GC - Copy SDB Inventory

Adds a button to your SDB page above your items. When clicked it copies all the items on the current page.

  1. // ==UserScript==
  2. // @name GC - Copy SDB Inventory
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @author AshyAsh
  6. // @description Adds a button to your SDB page above your items. When clicked it copies all the items on the current page.
  7. // @match https://www.grundos.cafe/safetydeposit/*
  8. // @grant GM_setClipboard
  9. // @license MIT
  10. // @icon https://www.google.com/s2/favicons?sz=64&domain=grundos.cafe
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Function to add custom CSS
  17. function addCustomCSS() {
  18. const css = `
  19. .custom-copy-button {
  20. background-color: #ACE1AF;
  21. border: 2px solid #6ECB73;
  22. padding: 5px 10px 15px 10px;
  23. margin: 10px;
  24. cursor: pointer;
  25. width: 85%;
  26. font-weight: 600;
  27. letter-spacing: 2px;
  28. text-transform: uppercase;
  29. }
  30.  
  31. .custom-copy-button:hover {
  32. background-color: #AFADE1;
  33. letter-spacing: 3px;
  34. border: 2px solid #726FCA;
  35. }
  36.  
  37. .custom-copy-button.copied {
  38. background-color: #03C03C;
  39. color: white;
  40. border: 2px solid #6ECB73;
  41. }
  42. `;
  43.  
  44. const head = document.head || document.getElementsByTagName('head')[0];
  45. const style = document.createElement('style');
  46. style.type = 'text/css';
  47. style.appendChild(document.createTextNode(css));
  48. head.appendChild(style);
  49. }
  50.  
  51. // Function to extract text and copy to clipboard
  52. function copyText() {
  53. let elements = document.querySelectorAll('.data.flex-column.small-gap.break strong');
  54. let textList = [];
  55.  
  56. elements.forEach(element => {
  57. textList.push(element.textContent);
  58. });
  59.  
  60. GM_setClipboard(textList.join("\n"));
  61.  
  62. // Change button appearance upon successful copy
  63. copyButton.classList.add('copied');
  64. copyButton.textContent = 'Items Copied!';
  65. }
  66.  
  67. // Add custom CSS to the page
  68. addCustomCSS();
  69.  
  70. // Create and insert a button to trigger the copy function
  71. let copyButton = document.createElement('button');
  72. copyButton.textContent = 'Copy Inventory';
  73. copyButton.className = 'custom-copy-button';
  74. copyButton.addEventListener('click', function(event) {
  75. event.preventDefault(); // Prevent any default button behavior
  76. copyText();
  77. });
  78.  
  79. // Select the target element to place the button above
  80. let targetElement = document.querySelector('.market_grid.sdb.margin-1');
  81.  
  82. if (targetElement) {
  83. targetElement.parentNode.insertBefore(copyButton, targetElement);
  84. }
  85. })();