Skip to content

Instantly share code, notes, and snippets.

@petitJAM
Last active November 7, 2019 15:43
Show Gist options
  • Save petitJAM/b722e657bc306c66d8336ee652d60c88 to your computer and use it in GitHub Desktop.
Save petitJAM/b722e657bc306c66d8336ee652d60c88 to your computer and use it in GitHub Desktop.
Bookmark JS for collapsing junk iOS files on GitHub PRs
/*
* Paste the following into a new bookmark, then click it on
* a GitHub PR to mark all the yucky Pod files as viewed.
*/
javascript:Array.from(document.querySelectorAll('a[title*=".xcodeproj"],a[title$=".storyboard"],a[title$=".pbxproj"],a[title^="Pods/"],a[title="Podfile.lock"]')).map(el => el.closest('.file-header').querySelector('.js-reviewed-checkbox')).forEach(function(el, i) { if (!el.checked) { el.click() } })
/*
* Readable version
*/
// Make the bookmark run JavaScript
javascript:
// querySelectorAll returns a NodeList, so we need to convert that to an Array
Array.from(
// Find links with the appropriate titles
document.querySelectorAll(
'a[title*=".xcodeproj"],a[title$=".storyboard"],a[title$=".pbxproj"],a[title^="Pods/"],a[title="Podfile.lock"]'
)
)
// Map over the links and find the checkbox that's part of that file header
.map(el => el.closest('.file-header').querySelector('.js-reviewed-checkbox'))
// Click them if they're unchecked
.forEach(function(el, i) { if (!el.checked) { el.click() } })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment