Skip to content

Instantly share code, notes, and snippets.

@raulb
Created March 9, 2026 09:24
Show Gist options
  • Select an option

  • Save raulb/cae1a0276d7775971a516a1c4a0c3fe8 to your computer and use it in GitHub Desktop.

Select an option

Save raulb/cae1a0276d7775971a516a1c4a0c3fe8 to your computer and use it in GitHub Desktop.
Bookmarklet to Clean GitHub notifications
javascript:(function(){let pageCount=0;const maxPages=50;function processCurrentPage(){pageCount++;console.log(`\n=== Processing Page ${pageCount} ===`);const listItems=document.querySelectorAll('[data-notification-id]');const actionIcons=['octicon-git-pull-request-closed','octicon-git-merge','octicon-issue-closed','octicon-git-pull-request-draft'];const ignoredWords=['ionic','flutter'];const ciActivityKeyword='ci activity';const approvalKeyword='approval requested';const rowsToClose=Array.from(listItems).filter((item)=>{let shouldClose=false;const iconElement=item.querySelector('svg.octicon');if(iconElement){const iconClass=Array.from(iconElement.classList).find(c=>c.startsWith('octicon-'));if(iconClass&&actionIcons.includes(iconClass)){shouldClose=true;}if(iconClass==='octicon-rocket'){shouldClose=true;}}const titleElement=item.querySelector('.markdown-title');if(titleElement){const text=titleElement.textContent.toLowerCase();if(ignoredWords.some(word=>text.includes(word))||text.includes('workflow run')||text.includes('requested your review')){shouldClose=true;}}const ciLabel=item.querySelector('.notification-list-item-actions-responsive')?.parentElement?.textContent||%27%27;if(ciLabel.includes(ciActivityKeyword)||ciLabel.includes(approvalKeyword)){shouldClose=true;}return shouldClose;});console.log(`Found ${rowsToClose.length} notifications to clear`);if(rowsToClose.length===0){console.log(%27Page is empty, checking for next button...%27);setTimeout(checkForNextPage,1000);return;}rowsToClose.forEach((item,index)=>{setTimeout(()=>{const doneForm=item.querySelector(%27form[data-status="archived"]%27);if(doneForm){const submitBtn=doneForm.querySelector(%27button[type="submit"]%27);if(submitBtn){submitBtn.click();console.log(`Clicked notification ${index+1}/${rowsToClose.length}`);}}},index*200);});setTimeout(processCurrentPage,rowsToClose.length*200+3000);}function checkForNextPage(){const nextBtn=document.querySelector(%27a.btn[aria-label="Next"]:not([disabled])%27);if(nextBtn&&pageCount<maxPages){console.log(%27πŸ“„ Next button found, clicking...%27);nextBtn.click();setTimeout(()=>{console.log(%27⏳ Waiting for page to load...%27);processCurrentPage();},3000);}else{console.log(%27βœ… All notifications cleared!%27);}}processCurrentPage();})();
@raulb
Copy link
Author

raulb commented Mar 9, 2026

Watch out! You might be rate limited by GitHub πŸ‘€

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