Skip to content

Instantly share code, notes, and snippets.

@korkey128k
Created December 12, 2023 14:35
Show Gist options
  • Save korkey128k/a60cad6849be244138222eaf173d0b73 to your computer and use it in GitHub Desktop.
Save korkey128k/a60cad6849be244138222eaf173d0b73 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Add Chain Icons to Watchlist
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Add icons to tokens in your watchlist for dexscreener
// @author Korkey128k
// @match https://dexscreener.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=dexscreener.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
const stylez = document.createElement('style')
stylez.innerHTML = `
@keyframes nodeInserted {
from { opacity: 0.99; }
to { opacity: 1; }
}
body div > nav div:nth-last-of-type(2) a[href*="0x"] {
animation-duration: 0.5s;
animation-name: nodeInserted;
}
`
document.head.appendChild(stylez);
document.addEventListener("animationend", function(event) {
if (event.animationName == "nodeInserted") {
setImg(event.target)
}
}, false);
function setImg(el) {
if(el.querySelector('span:first-of-type img') == null) {
const spanEl = el.querySelector('span:first-of-type'),
chainLabel = el.href.match(/(\w+)\/0x/)[1],
chainImg = document.querySelector(`.ds-nav-main-list .ds-nav-link[href="/${chainLabel}"] img`)
spanEl.style.display = 'flex'
spanEl.style.alignItems = 'center'
spanEl.style.gap = '0.3em'
spanEl.insertAdjacentElement('afterbegin', chainImg.cloneNode())
spanEl.querySelector('img').style.width = '15px'
spanEl.querySelector('img').style.height = '15px'
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment