Skip to content

Instantly share code, notes, and snippets.

@rrichardsonv
Last active November 30, 2018 21:54
Show Gist options
  • Select an option

  • Save rrichardsonv/9d97a5b7a65376b9af5c67e902692124 to your computer and use it in GitHub Desktop.

Select an option

Save rrichardsonv/9d97a5b7a65376b9af5c67e902692124 to your computer and use it in GitHub Desktop.
Github Console Scripts and Utils
function githubCollapseAll(){
const buttons = document.getElementsByTagName('button');
let results = [];
for(let i = 0, j = buttons.length; i<j; i++) {
let button = buttons[i]['attributes']['aria-label']
if(button && button['value'] === "Toggle diff contents"){
buttons[i].click();
}
}
}
function collectionToArray(collection){
let i = -1;
const result = [];
const len = collection.length;
while(++i < len){
result[i] = collection[i];
}
return result;
}
function filterOutZeroDiff(array){
const NO_CHANGE = 'File renamed without changes';
return array.filter((el) => el['attributes']['aria-label'].value === NO_CHANGE)
}
const getEmptyFiles = () => {
return filterOutZeroDiff(
collectionToArray(
document.getElementsByClassName('diffstat tooltipped tooltipped-e')
)
);
};
function prLevelPete(){
gitHubCollapseAll();
(getEmptyFiles()||[]).forEach((el) => el.offsetParent.innerHTML = '');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment