It is possible to do this using Google Apps Script.
- Go to Google Apps Script, and make sure you are logged into the Google account associated with the Gmail account in question
- Create a new project
- Copy and paste the code below into the project, click on the project title and change the name to something like "Bitcoin begone", then save
- Create a time based trigger to run the script on a schedule (every 1 minute, 1 hour, etc.)
You can replace var searchText = "bitcoin";
with var searchText = "subject:bitcoin";
to only delete messages with bitcoin in the subject, rather than anywhere in the email.
function deleteSpam() {
// "me" runs the script under the currently logged in Google account
var userId = "me";
var searchText = "bitcoin";
var threads = GmailApp.search("in:spam " + searchText);
for (var i = 0; i < threads.length; i++) {
Gmail.Users.Messages.remove(userId, threads[i].getId());
}
}
BE EXTREMELY CAREFUL!! It's possible to accidentally delete the wrong emails if you make a mistake in the script. You can test the script before creating a trigger by changing the searchText value to something else and dragging a sacrificial email into the spam folder, save the changes, then click Run on the project and see what happens. It's also not a bad idea to test scripts on a separate Gmail account first if you're not 100% comfortable with this type of scripting.
If there are certain senders or terms that would indicate that a message is not spam, you can create a regular Gmail filter to prevent those emails from going to spam in the first place. Create a filter matching emails that will never be spam and check the "Never send to spam" checkbox in the filter.