Created
June 19, 2019 15:17
-
-
Save lynn/44325fa71777b1ccdf8d40ba1bd68bb4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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