Last active
January 27, 2021 20:34
-
-
Save lyahdav/30fabcfb2856a28d320114922c91a1e3 to your computer and use it in GitHub Desktop.
Tampermonkey script to Show Total Number of Lines Modified in Phabricator Diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
legend!! 😛