Last active
July 28, 2025 11:30
-
-
Save freakynit/1f472c92e01f7e77287c727c6df0436c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function filterNoisyGithubCommentEmails(subject, list, days) { | |
days = (typeof days === "undefined" || days === null || isNaN(days)) ? 1 : days; | |
var query = []; | |
if (list) query.push('list:' + list); | |
if (subject) query.push('subject:"' + subject + '"'); | |
if (days) query.push('newer_than:' + days + 'd'); | |
var searchString = query.join(' '); | |
const patterns = [ | |
/(\+1|๐)/i, | |
/i want (this|it) (feature|too)?/i, | |
/(this|it) (would be )?(great|useful|awesome)/i, | |
/please (add|implement|support)/i, | |
/waiting for (this|feature)/i, | |
/(any updates?|update)( on this)?\??/i, | |
/me too/i, | |
/following|interested/i, | |
/hope (this )?happens soon/i, | |
/hoping (this )?happens soon/i, | |
/any (news|updates) on (this|it)?/i, | |
/are we (going to )?have (anything|something) here/i, | |
/(do )?you have (any )?(rough )?eta/i, | |
/when can (i|we) use/i, | |
/please enable (this|it)/i, | |
/i'?m looking forward( to (it|this))?/i, | |
/looking forward( to (it|this))?/i, | |
]; | |
function matchCount(text) { | |
text = text.trim().toLowerCase(); | |
return patterns.reduce(function(count, regex) { | |
return count + (regex.test(text) ? 1 : 0); | |
}, 0); | |
} | |
var threads = GmailApp.search(searchString); | |
for (var i = 0; i < threads.length; i++) { | |
var messages = threads[i].getMessages(); | |
for (var j = 0; j < messages.length; j++) { | |
var message = messages[j]; | |
var body = message.getPlainBody(); | |
if (matchCount(body) === 1) { // Only trash if exactly one pattern matched | |
message.moveToTrash(); | |
Logger.log("Trashed email: " + message.getSubject()); | |
} | |
} | |
} | |
} | |
// Example usage: | |
// subject, list, how many days old ... all optional | |
filterNoisyGithubCommentEmails('An IntelliJ-based plugin', 'cline.cline.github.com', 1); | |
// Reference: https://github.com/cline/cline/discussions/581#discussioncomment-12290734 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Equivalent browser console script to dim or hide such comments: