Skip to content

Instantly share code, notes, and snippets.

@DV8FromTheWorld
Last active January 15, 2022 20:07
Show Gist options
  • Save DV8FromTheWorld/b0bfc2bfbeb4b10e581e66154599ccc8 to your computer and use it in GitHub Desktop.
Save DV8FromTheWorld/b0bfc2bfbeb4b10e581e66154599ccc8 to your computer and use it in GitHub Desktop.
(() => {
/* Finds the "Viewed" button for each file, selecting only ones marked as already viewed */
const allViewedFiles = Array.from(document.querySelectorAll('[data-ga-click="File viewed, click, value:true"]'));
/* Iterates through the viewed files and closes any that are still open. */
const allOpenViewedFiles = allViewedFiles.forEach(viewedButton => {
const fileContainer = viewedButton.closest('.js-details-container');
if (fileContainer.classList.contains('open')) {
const collapseButton = fileContainer.querySelector('.js-details-target');
collapseButton.click();
}
})
})();
@DV8FromTheWorld
Copy link
Author

DV8FromTheWorld commented Jan 15, 2022

Make the URL for a bookmark be:
javascript: <code>

Simply click the bookmark to collapse all PR files that have already been viewed.

close-already-viewed-pr-files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment