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

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs