Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ==UserScript==
// @name annotate twitter usernames
// @namespace https://twitter.com/chordbug
// @version 0.1
// @description annotate twitter usernames
// @author lynn
// @match https://twitter.com/*
// @grant GM_addStyle
// ==/UserScript==
(function() {
'use strict';
GM_addStyle(`
.meow-annotation {
/* Same style as "Follows You", but different color */
background-color: #e6bcc0;
border-radius: 4px;
color: #653746;
font-size: 12px;
font-weight: normal;
margin-left: 2px;
padding: 2px 4px;
}
`);
const annotations = {
'rrika9': 'cutie',
'chordbug': 'moth!!',
};
function annotate() {
for (const b of document.querySelectorAll('div.ProfileCard-content a.ProfileCard-screennameLink>span.username>b')) {
const username = b.innerText;
const span = b.parentElement.parentElement.parentElement;
if (annotations[username] && span.lastChild.className !== 'meow-annotation') {
const textNode = document.createTextNode(annotations[username]);
const annotationSpan = document.createElement('SPAN');
annotationSpan.appendChild(textNode);
annotationSpan.className = 'meow-annotation';
span.appendChild(annotationSpan);
}
}
}
setInterval(annotate, 1000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.