Skip to content

Instantly share code, notes, and snippets.

@kpittman-securus
Last active May 7, 2021 21:20
Show Gist options
  • Save kpittman-securus/83097da5ea99a4fa245db8e3fd3142b4 to your computer and use it in GitHub Desktop.
Save kpittman-securus/83097da5ea99a4fa245db8e3fd3142b4 to your computer and use it in GitHub Desktop.
Mark deleted as viewed, sort all files by number of changes
const container = $('#files');
const files = Array.from($$('.file'));
const getSortText = (el) => parseInt(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