Skip to content

Instantly share code, notes, and snippets.

@mansona
Created May 12, 2021 22:18
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mansona/0726ecb7150cff456b3f5f0df198d13a to your computer and use it in GitHub Desktop.
This is a super simple snippet that I paste into my browser console to clear github notifications. Once It has been run once I just push up-enter-up-enter until they are all gone!
let foundStuff = false;
let items = document.querySelectorAll('li.notifications-list-item')
items.forEach((item) => {
if(item.querySelector('img.avatar-user[alt="@dependabot-preview[bot]"]') || item.querySelector('img.avatar-user[alt="@dependabot[bot]"]') || item.querySelector('img.avatar-user[alt="@renovate[bot]"]')) {
console.log('did find one');
foundStuff = true;
item.querySelector('input[type="checkbox"]').click();
}
});
if(foundStuff) {
foundStuff = false;
console.log('found some stuff - refresh');
document.querySelector('button[Title="Done"]').click();
setTimeout(() => window.location.reload(), 200);
} else {
console.log('found nothing, next page');
setTimeout(() => {
document.querySelector('a[aria-label="Next"]').click();
}, 200);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment