Marking All Files in a GitHub Pull Request as Viewed

9th April 2023

Marking All Files as Viewed

Working through a large pull request (PR) review on GitHub often means jumping around, trying to determine how different pieces of the code interact, or getting pulled away to work on something completely different. When there are tens or even hundreds of files to review it can be easy to lose track of where you are.

Thankfully GitHub offers us the ability to mark a file as reviewed. Clicking the checkbox collapses the view of that particular file, so even if we walk away and come back to it later, we know that particular file has been reviewed.

The Viewed checkbox on a GitHub PR

Even better; if you finish reviewing all the files in a PR and check all those boxes, when any new commits are pushed it only un-checks the files that have been updated, so you don’t end up re-reviewing files that haven’t changed.

Sometimes though, it becomes necessary to re-review everything. Unfortunately, GitHub doesn't provide any way of checking or un-checking all the boxes at once. Thankfully, one handy little snippet is all we need to get the job done;

  • Open the developer console in your browser, by pressing F12 in Chrome or Firefox.
  • Find the Console tab and paste in the following snippet;
document.querySelectorAll(".js-reviewed-checkbox").forEach(checkbox => !checkbox.checked && checkbox.click());
  • Hit enter and voila! All the files are marked as viewed.

Marking All Files as Un-Viewed

If you want to start from scratch, marking all the files as un-viewed, use this code instead;

document.querySelectorAll(".js-reviewed-checkbox").forEach(checkbox => checkbox.checked && checkbox.click());

Then all the files will be marked as un-viewed, ready to be reviewed again.