Skip to content

Instantly share code, notes, and snippets.

@kwiniarski97
Last active December 15, 2020 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kwiniarski97/cf5b472139af75eb51f89c3128c13100 to your computer and use it in GitHub Desktop.
Save kwiniarski97/cf5b472139af75eb51f89c3128c13100 to your computer and use it in GitHub Desktop.
// ==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