Ever get stuck clicking through endless "Load diff" buttons on a giant GitHub pull request? It's the worst, right? While Iβm all for using VSCode for reviews (seriously, check out my other post on that), if youβre sticking with GitHub, you can run a simple script in your browser's console to reveal all sections for you.
Paste the script to browser's console
The following script automates what you'd do manually - clicking all buttons to load the diffs β saving you time and effort:
// Expand all "Load diff" buttons in a GitHub PR's /files page
clickLoadDiff = () => {
buttons = [...document.querySelectorAll('.load-diff-button')];
if (buttons.length) {
console.log(buttons);
buttons.forEach((x) => setTimeout(() => x.click()));
console.log('Load diff - clicked');
setTimeout(clickLoadDiff, 1000);
} else {
console.log('Load diff - no items to click');
}
};
clickLoadDiff();
How It Works
-
Find the Buttons: The script searches for all elements with the class
.load-diff-button
. -
Click Them: It clicks each button, using
setTimeout
to ensure each click is processed smoothly (in a separate JS macrotask). - Repeat if Necessary: After a second, it checks if there are more buttons to click and repeats the process until there are none left.
If you really feel like buying me a coffee
... then feel free to do it. Many thanks! π
Top comments (0)