Skip to content

Instantly share code, notes, and snippets.

@bpceee
Last active November 21, 2018 09:29
Show Gist options
  • Save bpceee/b33aba28527394c10bd79f24dadcb826 to your computer and use it in GitHub Desktop.
Save bpceee/b33aba28527394c10bd79f24dadcb826 to your computer and use it in GitHub Desktop.
stash avatar initials
// ==UserScript==
// @name stash avatar initials
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://stash.bbpd.io/*
// @grant none
// ==/UserScript==
const styleEl = document.createElement('style');
document.head.appendChild(styleEl);
styleEl.sheet.insertRule('.aui-avatar-inner { background-color: lightgray; color: white; font-weight: 700; line-height: 32px; }', 0);
styleEl.sheet.insertRule('.aui-avatar-small .aui-avatar-inner { line-height: 24px; }', 0);
const observer = new MutationObserver(function(mutations) {
document.querySelectorAll('img[src^="https://secure.gravatar.com"]').forEach((img) => {
const parent = img.parentElement;
const initials = img.alt.split(' ').map(s=>s[0]).join('');
parent.textContent = initials;
})
})
observer.observe(document, { childList: true, subtree: true });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment