Last active
December 15, 2020 16:10
-
-
Save kwiniarski97/cf5b472139af75eb51f89c3128c13100 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 Avatar Next To Name In PR | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description This extension make author's name more recognizable in PR view as it adds a user avatar next to username. Also adds a underline to username. | |
// @author kwiniarski97 | |
// @match https://github.com/*/pulls | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const parents = Array.from(document.querySelectorAll('.opened-by')); | |
const links = Array.from(document.querySelectorAll('.opened-by a')); | |
// make usernames underscored | |
links.forEach(link => (link.style.textDecoration = 'underline')); | |
// add images | |
const images = links | |
.map(link => link.innerText) | |
.map(username => { | |
const image = document.createElement('img'); | |
image.src = `https://github.com/${username}.png?size=16`; | |
image.style.height = "16px"; | |
image.style.width = "16px"; | |
image.style.marginTop = "-8px"; | |
image.alt = `${username}'s avatar`; | |
return image; | |
}); | |
for(let i = 0; i < links.length; i++) { | |
parents[i].insertBefore(images[i], null); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment