Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

NicoHinderling commented Jan 31, 2019

legend!! 😛

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.