Created
January 27, 2021 21:05
-
-
Save keyan/82237d61821840a07dafc2ad002bc00a to your computer and use it in GitHub Desktop.
Tapermonkey script that adds a text element to the top of a phabricator diff page with the total diff size. Doesn't have a +/- breakdown because that info isn't easy to access. This is to circumvent maintainers that refuse to add features, see https://secure.phabricator.com/T11768.
This file contains hidden or 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 https://phabricator.dropboxer.net/D* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var files = document.getElementsByClassName('right aphront-table-view-nodevice'); | |
var totalLineCount = 0; | |
for (var i=1;i<files.length; i++) { | |
var file = files[i]; | |
var lineText = file.textContent; | |
lineText = lineText.match(/(.+) lines/); | |
if (lineText == null) { continue; } | |
var lineCount = parseInt(lineText[1]); | |
totalLineCount += lineCount; | |
} | |
var countElementContent = document.createTextNode('Total number of lines modified: ' + totalLineCount); | |
var countElement = document.createElement('span'); | |
countElement.appendChild(countElementContent); | |
countElement.style = 'font-size: 16px; color: rgb(151,234,151)'; | |
document.getElementsByClassName('phui-header-subheader')[0].appendChild(countElement); | |
console.log(totalLineCount); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based off https://gist.github.com/lyahdav/30fabcfb2856a28d320114922c91a1e3, which only some small changes to work with the next element classnames as the phabricator UI has changed.