Skip to content

Instantly share code, notes, and snippets.

@dound
Created October 13, 2023 00:15
Show Gist options
  • Save dound/593e4a9aef6ddf9021dc065e5f4b6b04 to your computer and use it in GitHub Desktop.
Save dound/593e4a9aef6ddf9021dc065e5f4b6b04 to your computer and use it in GitHub Desktop.
Hide certain file paths in a GitHub PR
function markMatchingFilesAsViewed() {
// hide files with GeneratedCode in their path, or ending with .meta or .asset
const regex = /(GeneratedCode)|(.meta$)|(.asset$)/
const fileDivs = document.getElementsByClassName('file-header');
let numMatches = 0;
let numClicks = 0;
for (const fileDiv of fileDivs) {
const filePath = fileDiv.getElementsByClassName('Truncate')[0]?.children[0]?.getAttribute('title') ?? ''
if (filePath.match(regex)) {
console.log(filePath);
numMatches += 1;
const checkbox = fileDiv.getElementsByClassName('js-reviewed-checkbox')[0];
if (!checkbox.checked) {
checkbox.click();
numClicks += 1;
}
}
}
console.log(`${numMatches} of ${files.length} files matched; toggled ${numClicks} from unviewed to viewed`);
}
markMatchingFilesAsViewed()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment