-
-
Save monkpit/2070c5204625d64f3eea588d5e00e934 to your computer and use it in GitHub Desktop.
Mark deleted as viewed, sort all files by number of changes
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
const container = $('#files'); | |
const files = Array.from($$('.file')); | |
const getSortText = (el) => el.querySelector('.diffstat').innerText; | |
files.sort((a, b) => { | |
const aSortText = getSortText(a); | |
const bSortText = getSortText(b); | |
if (aSortText > bSortText) return 1; | |
if (aSortText < bSortText) return -1; | |
return 0; | |
}); | |
container.innerHTML = '' | |
for (const file of files) { | |
container.appendChild(file); | |
} | |
const openFiles = Array.from($$('.file.open')); | |
const deletions = openFiles.filter(file => file.querySelector('.diffstat[aria-label*=": 0 additions"]')); | |
const markAsViewed = (fileEl) => fileEl.querySelector('[class*=reviewed-toggle]').click(); | |
deletions.map(markAsViewed); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment