Last active
November 30, 2018 21:54
-
-
Save rrichardsonv/9d97a5b7a65376b9af5c67e902692124 to your computer and use it in GitHub Desktop.
Github Console Scripts and Utils
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
| 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