Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Github PR bookmarklet: Load all file diffs
javascript:
document.querySelectorAll('.load-diff-button').forEach(node => node.click())
@benguild
Copy link

benguild commented Oct 17, 2017

Thanks, I use this all of the time.

@chri7325
Copy link

chri7325 commented Dec 28, 2017

Awesome. Will save me quite a lot of carpel-tunnel clicks.

@sarojkh
Copy link

sarojkh commented May 22, 2018

Thank you. Bookmarked.

@melfa
Copy link

melfa commented Mar 29, 2019

Load first 50 files with only "Load Diff" button, without reason (this exclude large files, deleted files and so on):
Array.from(document.querySelectorAll('.js-diff-load-button-container')).filter(container => !container.querySelector('.hidden-diff-reason')).slice(0, 50).forEach(container => container.querySelector('.load-diff-button').click())

@uttamraj-pando
Copy link

uttamraj-pando commented Apr 28, 2020

awesome.would have received lot of upvotes in stackoverflow

@ElectricRCAircraftGuy
Copy link

ElectricRCAircraftGuy commented Oct 8, 2020

@juanca
Copy link
Author

juanca commented Oct 9, 2020

oh, if you're keeping a collection around. here is another i use pretty regularly:

https://gist.github.com/juanca/669c59f15a17e20022b8bd78b12889e6

@s0undt3ch
Copy link

s0undt3ch commented Apr 27, 2021

Only click on files which are not yet marked as reviewed.

Array.from(document.querySelectorAll('.file')).filter(container => !container.querySelector('input.js-reviewed-checkbox:checked')).filter(container => container.querySelector('.load-diff-button')).forEach(node => node.click())

@s0undt3ch
Copy link

s0undt3ch commented Apr 27, 2021

Nope, that doesn't work :/

@s0undt3ch
Copy link

s0undt3ch commented Apr 27, 2021

Ah ha!

Array.from(document.querySelectorAll('.file')).filter(container => !container.querySelector('input.js-reviewed-checkbox:checked')).forEach(pnode => pnode.querySelectorAll('.load-diff-button').forEach(node => node.click()))

@AronNovak
Copy link

AronNovak commented May 4, 2021

image
Well, use it carefully for large pull requests, you can easily end up with being blocked.

@s0undt3ch
Copy link

s0undt3ch commented May 4, 2021

Well, that really must be a massive PR.
Mine was ~1.6k files changed and I never hit that...

@AronNovak
Copy link

AronNovak commented May 4, 2021

image
I was blocked for such a PR. But the block only took for a few minutes, not hours fortunately.

@juanca
Copy link
Author

juanca commented May 12, 2021

Woah, I guess we could batch the requests for x files at a time? Might seem a bit excessive for a bookmark though. Up to anyone else if they want to improve on the script.

@mcoberly2
Copy link

mcoberly2 commented Jul 21, 2021

Thanks! I just put the Javascript in my browser URI field and voila!

@ScriptAutomate
Copy link

ScriptAutomate commented Aug 6, 2021

I had to modify a little:

Array.from(document.getElementsByClassName('load-diff-button')).map(button => button.click())`

https://gist.github.com/ScriptAutomate/a3240e8767f0e8e70644ebf3ca4b74fb#github-reviewing-prs-with-tons-of-modified-files-and-load-diff-buttons

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment