Skip to content

Instantly share code, notes, and snippets.

@lyahdav
Last active January 27, 2021 20:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lyahdav/30fabcfb2856a28d320114922c91a1e3 to your computer and use it in GitHub Desktop.
Save lyahdav/30fabcfb2856a28d320114922c91a1e3 to your computer and use it in GitHub Desktop.
Tampermonkey script to Show Total Number of Lines Modified in Phabricator Diff
// ==UserScript==
// @name Show Total Number of Lines Modified in Diff
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Show total number of lines modified in diff at bottom of table of contents
// @author lyahdav
// @match UPDATE HERE e.g. https://phab.example.com/D*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var files = document.getElementsByClassName('differential-toc-file');
var totalLineCount = 0;
for (var i=1;i<files.length; i++) {
var file = files[i];
if (file.childNodes.length != 2) {
continue;
}
var lineText = file.childNodes[1].textContent;
lineText = lineText.match(/\((.+) /)[1];
var lineCount = parseInt(lineText);
totalLineCount += lineCount;
}
var countElementContent = document.createTextNode('Total number of lines modified: ' + totalLineCount);
var countElement = document.createElement('span');
countElement.appendChild(countElementContent);
countElement.className = 'differential-toc-file';
countElement.style = 'font-size: 12px;';
document.getElementsByClassName('differential-toc-buttons')[0].appendChild(countElement);
})();
@NicoHinderling
Copy link

legend!! 😛

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment