Skip to content

Instantly share code, notes, and snippets.

@xkxd
Created January 26, 2017 00:23
Show Gist options
  • Select an option

  • Save xkxd/33bf6494f501721360fb461668a46c16 to your computer and use it in GitHub Desktop.

Select an option

Save xkxd/33bf6494f501721360fb461668a46c16 to your computer and use it in GitHub Desktop.
get total number of lines of code in github repository
// go to `Contributors` and paste this in console
function linesOfCode(addedCssSelector = '.a', removedCssSelector = '.d') {
const repoName = document.querySelector('[itemprop=name] a').innerText;
const getLOC = (selector) =>
Array.from(document.querySelectorAll(`.cmeta ${selector}`))
.reduce(((sum, element) =>
sum += +element.innerText.replace(',','').slice(0, -2)), 0)
return `Total number of LOC in >>${repoName}<< repository is ${getLOC(addedCssSelector) - getLOC(removedCssSelector)}`;
}
linesOfCode();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment