DEV Community

Krzysztof Platis
Krzysztof Platis

Posted on

How to Reveal All "Load Diff" Sections in a GitHub PR πŸ’«

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();
Enter fullscreen mode Exit fullscreen mode

How It Works

  1. Find the Buttons: The script searches for all elements with the class .load-diff-button.
  2. Click Them: It clicks each button, using setTimeout to ensure each click is processed smoothly (in a separate JS macrotask).
  3. 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! πŸ™Œ

Buy Me A Coffee

Top comments (0)