Skip to content

Instantly share code, notes, and snippets.

@andrhamm
Created January 27, 2013 17:44
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 andrhamm/4649393 to your computer and use it in GitHub Desktop.
Save andrhamm/4649393 to your computer and use it in GitHub Desktop.
Wanted to take a screenshot of GitHub diff-stats UI but didn't want to count some of the files/changes in the commit so I wrote a quick script to update them after deleting unwanted nodes from the DOM.
/*
* Use Chrome web inspector to remove elements for files
* you don't want to count in the diff stats, then run this
* function to update the diff stats in the UI
*/
function () {
var allAdditions = 0;
$(".diffstat > a").each( function (index, element) {
$(".diffstat-bar", this).remove();
var addition = $.trim($(this).text().replace(/[A-Za-z$-]/g, ""));
allAdditions += parseInt(addition);
});
var allFiles = $("#toc > .content li").size();
console.log(allFiles+' files changed with '+ allAdditions +' additions')
// update the dom
$("#toc > .explain > strong").eq(1).text( allAdditions + " additions");
$("#toc > .explain > strong").eq(0).text( allFiles + " changed files");
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment