Advertisement
Guest User

Untitled

a guest
Jan 20th, 2025
3,620
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Modify Classes and Inject CSS on neo.bullx.io
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.4
  5. // @description Renames specific classes and injects custom CSS on https://neo.bullx.io/
  6. // @author TwizzyGen
  7. // @match https://neo.bullx.io/*
  8. // @grant none
  9. // @run-at document-end
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. const classMappings = {
  16. 'pum-card': 'pump-card',
  17. 'chartsss': 'charts'
  18. };
  19.  
  20. function replaceClasses(el) {
  21. for (const [oldClass, newClass] of Object.entries(classMappings)) {
  22. if (el.classList.contains(oldClass)) {
  23. el.classList.replace(oldClass, newClass);
  24. }
  25. }
  26. }
  27.  
  28. function processNode(node) {
  29. if (node.nodeType !== 1) return;
  30. replaceClasses(node);
  31. node.querySelectorAll(Object.keys(classMappings).map(cls => `.${cls}`).join(',')).forEach(child => {
  32. replaceClasses(child);
  33. });
  34. }
  35.  
  36. function injectCustomCSS() {
  37. const css = `
  38. .pump-card {
  39. position: relative;
  40. display: flex;
  41. height: 112px;
  42. width: 100%;
  43. align-items: center;
  44. border-top-width: 1px;
  45. --tw-border-opacity: 1;
  46. border-color: hsl(var(--twc-grey-500) / var(--twc-grey-500-opacity, var(--tw-border-opacity)));
  47. padding: 0.75rem;
  48. }
  49.  
  50. @media (min-width: 768px) {
  51. .pump-card {
  52. height: 106px;
  53. padding: 1rem;
  54. }
  55. }
  56. `;
  57. const style = document.createElement('style');
  58. style.type = 'text/css';
  59. style.appendChild(document.createTextNode(css));
  60. document.head.appendChild(style);
  61. }
  62.  
  63. function initialize() {
  64. for (const [oldClass, newClass] of Object.entries(classMappings)) {
  65. document.querySelectorAll(`.${oldClass}`).forEach(el => replaceClasses(el));
  66. }
  67. injectCustomCSS();
  68. }
  69.  
  70. function setupMutationObserver() {
  71. const observer = new MutationObserver((mutations) => {
  72. mutations.forEach(mutation => {
  73. mutation.addedNodes.forEach(node => {
  74. processNode(node);
  75. });
  76.  
  77. if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
  78. const target = mutation.target;
  79. replaceClasses(target);
  80. }
  81. });
  82. });
  83.  
  84. observer.observe(document.body, {
  85. childList: true,
  86. subtree: true,
  87. attributes: true,
  88. attributeFilter: ['class']
  89. });
  90. }
  91.  
  92. initialize();
  93. setupMutationObserver();
  94.  
  95. })();
  96.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement