Skip to content

Instantly share code, notes, and snippets.

@sleeyax
Last active May 2, 2019 15:47
Show Gist options
  • Save sleeyax/6eb9e7bfeb286f8c801f6c35ec384cc0 to your computer and use it in GitHub Desktop.
Save sleeyax/6eb9e7bfeb286f8c801f6c35ec384cc0 to your computer and use it in GitHub Desktop.
Calculate additions - deletions in the contributors graph on github
// ==UserScript==
// @name Github contributors graph addon
// @author Sleeyax
// @namespace Violentmonkey Scripts
// @match https://github.com/*/graphs/contributors
// @grant none
// @inject-into content
// ==/UserScript==
var x = setInterval(function() {
var added = document.getElementsByClassName("text-green");
var deleted = document.getElementsByClassName("text-red");
for (var i=0; i<added.length; i++) {
var a = added[i].innerText.replace(",", "").replace(" ++", "");
var b = deleted[i].innerText.replace(",", "").replace(" --", "");
var c = a - b;
deleted[i].insertAdjacentHTML("afterEnd", '<span class="text-blue text-normal"> ' + c +' diff</span>');
}
if (document.getElementsByClassName("text-blue").length > 0) {
clearInterval(x);
}
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment