Last active
December 24, 2023 14:32
-
-
Save potato4d/a08ade97d65ff882e5751fb85c7b6a6a to your computer and use it in GitHub Desktop.
The Google App script for clean up your Gmail Inbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Gmail Cleaner v0.1.0 | |
* publishedAt: 2020/10/25 | |
* Author: @potato4d | |
* LICENSE: MIT | |
**/ | |
// TODO: Customize | |
const target = [ | |
'notifications@github.com', | |
'builds@circleci.com' | |
] | |
function cleanupThreads() { | |
if (!target.length) { | |
return | |
} | |
console.log('Search threads..') | |
const threads = GmailApp.search(`label: unread AND (from: ${target.join(' OR from: ')})`) | |
console.log('Threads count :' + threads.length) | |
threads.forEach((thread) => { | |
thread.markRead() | |
// If you want to add to the trash | |
// thread.moveToTrash() | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Excellent idea for targets. FYI https://github.com/Cyber-Copilot/GmailCleaner