How to reveal all "Load Diff" sections in a GitHub PR 💫
Krzysztof Platis

Krzysztof Platis @krisplatis

About: Welcome to my blog. I'm Javascript Enthusiast • Fascinated with internals of Vue, React and Angular • Focused on the business needs of Clients • Architect @ SAP Spartacus core team. Opinions R my own

Joined:
Nov 22, 2019

How to reveal all "Load Diff" sections in a GitHub PR 💫

Publish Date: Jan 8
0 0

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

Comments 0 total

    Add comment