Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Modify Classes and Inject CSS on neo.bullx.io
- // @namespace http://tampermonkey.net/
- // @version 1.4
- // @description Renames specific classes and injects custom CSS on https://neo.bullx.io/
- // @author TwizzyGen
- // @match https://neo.bullx.io/*
- // @grant none
- // @run-at document-end
- // ==/UserScript==
- (function() {
- 'use strict';
- const classMappings = {
- 'pum-card': 'pump-card',
- 'chartsss': 'charts'
- };
- function replaceClasses(el) {
- for (const [oldClass, newClass] of Object.entries(classMappings)) {
- if (el.classList.contains(oldClass)) {
- el.classList.replace(oldClass, newClass);
- }
- }
- }
- function processNode(node) {
- if (node.nodeType !== 1) return;
- replaceClasses(node);
- node.querySelectorAll(Object.keys(classMappings).map(cls => `.${cls}`).join(',')).forEach(child => {
- replaceClasses(child);
- });
- }
- function injectCustomCSS() {
- const css = `
- .pump-card {
- position: relative;
- display: flex;
- height: 112px;
- width: 100%;
- align-items: center;
- border-top-width: 1px;
- --tw-border-opacity: 1;
- border-color: hsl(var(--twc-grey-500) / var(--twc-grey-500-opacity, var(--tw-border-opacity)));
- padding: 0.75rem;
- }
- @media (min-width: 768px) {
- .pump-card {
- height: 106px;
- padding: 1rem;
- }
- }
- `;
- const style = document.createElement('style');
- style.type = 'text/css';
- style.appendChild(document.createTextNode(css));
- document.head.appendChild(style);
- }
- function initialize() {
- for (const [oldClass, newClass] of Object.entries(classMappings)) {
- document.querySelectorAll(`.${oldClass}`).forEach(el => replaceClasses(el));
- }
- injectCustomCSS();
- }
- function setupMutationObserver() {
- const observer = new MutationObserver((mutations) => {
- mutations.forEach(mutation => {
- mutation.addedNodes.forEach(node => {
- processNode(node);
- });
- if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
- const target = mutation.target;
- replaceClasses(target);
- }
- });
- });
- observer.observe(document.body, {
- childList: true,
- subtree: true,
- attributes: true,
- attributeFilter: ['class']
- });
- }
- initialize();
- setupMutationObserver();
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement