Skip to content

Instantly share code, notes, and snippets.

@lynn
Created June 19, 2019 15:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lynn/44325fa71777b1ccdf8d40ba1bd68bb4 to your computer and use it in GitHub Desktop.
Save lynn/44325fa71777b1ccdf8d40ba1bd68bb4 to your computer and use it in GitHub Desktop.
// ==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