-
-
Save briandoesdev/2609ad550d1d530bb42f44aa06b8596f to your computer and use it in GitHub Desktop.
Gmail spam is entirely out of control in 2022
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
| // hah silly human # is for Python comments! | |
| // created in Google Apps Script and scheduled to run every minute | |
| function processInboxEmailSubjects() { | |
| var threads = GmailApp.search("is:unread newer_than:1d -label:spam") | |
| Logger.log("Examining " + threads.length + " threads for spam by checking the subject line") | |
| for (var i = 0; i < threads.length; i++) { | |
| var subject = threads[i].getFirstMessageSubject() | |
| const regex = /confirmation#/i | |
| let isSpam = regex.test(subject) | |
| // TODO other tests as necessary for your particular spam hell | |
| if (isSpam) { | |
| Logger.log("identified spam: " + subject) | |
| threads[i].moveToSpam() | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment