Skip to content

Instantly share code, notes, and snippets.

@kyletolle
Created December 18, 2023 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyletolle/52c78647a2a8b34a740e398620545f6d to your computer and use it in GitHub Desktop.
Save kyletolle/52c78647a2a8b34a740e398620545f6d to your computer and use it in GitHub Desktop.
Github PR review: Snippet to check viewed on files renamed without changes or deleted
// In a GitHub PR, you can run this script in a console to help automatically click the Viewed checkbox
// Worked as of 2023.12.18
// JS snippet to click 'Viewed' on files that were deleted entirely, not changed or renamed
Array.from(document.querySelectorAll('.js-diff-load')).forEach(fileInfo => {
const text = fileInfo.nextElementSibling.textContent.trim();
if(text.includes('This file was deleted.')) {
const viewedCheckbox = fileInfo.closest('.js-file.js-details-container').querySelector('.js-reviewed-checkbox');
if(viewedCheckbox && !viewedCheckbox.checked) {
viewedCheckbox.click();
}
}
});
// In a GitHub PR, you can run this script in a console to help automatically click the Viewed checkbox.
// Worked as of 2023.12.18
// JavaScript snippet to click 'Viewed' on files renamed without changes
Array.from(document.querySelectorAll('.data.highlight.empty')).forEach(fileInfo => {
const text = fileInfo.textContent.trim();
if(text.includes('File renamed without changes')) {
const viewedCheckbox = fileInfo.closest('.js-file.js-details-container').querySelector('.js-reviewed-checkbox');
if(viewedCheckbox && !viewedCheckbox.checked) {
viewedCheckbox.click();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment