Make a new bookmark in your browser. Set the name to Close all PR files
(or something else you like) and set the URL to:
javascript:void((function(d){d.querySelectorAll('div:not(.Details--on) > div.file-header > div.file-actions > button').forEach(function(x){x.click()});})(document));
Click the bookmark to close all files in your PR.
Based on ideas from @yardensachs and @benjamincharity.
This bookmarklet runs fairly slow for me, especially if I'm dealing with a lot of files to look through. I wrote this one up, trying to align it with how they collapse the sections internally. If they end up changing classes around, this could break one day, but for now it runs very quickly for me because it avoids having to run all the other on click event listeners registered on the page. Hope it helps others.
Here's one that collapses all:
Here's one that expands all (but doesn't load large diffs):
And here's one that expands all and should try to load large diffs, too: