Skip to content

Instantly share code, notes, and snippets.

@gasparportik
Created May 4, 2020 16:04
Show Gist options
  • Save gasparportik/0fd444237e2b706b2933ebd0979a16b3 to your computer and use it in GitHub Desktop.
Save gasparportik/0fd444237e2b706b2933ebd0979a16b3 to your computer and use it in GitHub Desktop.
Sort PR files by changes
(() => {
const diffCount = (elem) => Number((elem.querySelector('.diffstat').attributes['aria-label']?.value||'0').split(' ')[0]);
const files = document.getElementById('files');
Array.from(files.querySelectorAll('.file')).sort((a,b) => (a = diffCount(a),b=diffCount(b),a - b))
.forEach((item) => (item.remove(),files.appendChild(item)));
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment