Last active
August 29, 2015 14:24
-
-
Save michaelgold/4e4fbc1a0006e6b06ddc to your computer and use it in GitHub Desktop.
GMail Snoozes for Mailbox
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
var MARK_UNREAD = true; | |
var ADD_UNSNOOZED_LABEL = true; | |
function do_setup() { | |
GmailApp.createLabel("[Mailbox]"); | |
GmailApp.createLabel("[Mailbox]/Later Today"); | |
GmailApp.createLabel("[Mailbox]/This Weekend"); | |
GmailApp.createLabel("[Mailbox]/Tomorrow"); | |
GmailApp.createLabel("[Mailbox]/Next Week"); | |
GmailApp.createLabel("[Mailbox]/Next Month"); | |
GmailApp.createLabel("[Mailbox]/This Evening"); | |
GmailApp.createLabel("[Mailbox]/Wednesday"); | |
GmailApp.createLabel("!unsnoozed"); | |
} | |
function do_move(glabel) { | |
var page = glabel.getThreads(0, 100); | |
if (page.length > 0) { | |
GmailApp.moveThreadsToInbox(page); | |
if (MARK_UNREAD) { | |
for (var i = 0 ; i < page.length; i++) { | |
var messages = GmailApp.getMessagesForThread(page[i]); | |
var lastMessageID = messages.length-1; | |
GmailApp.markMessageUnread(messages[lastMessageID]); // mark last message as unread | |
} | |
} | |
if (ADD_UNSNOOZED_LABEL) { | |
GmailApp.getUserLabelByName("!unsnoozed").addToThreads(page); | |
} | |
glabel.removeFromThreads(page); | |
} | |
} | |
function moveLaters() { | |
do_move(GmailApp.getUserLabelByName("[Mailbox]/Later Today")); | |
} | |
function moveWeekends() { | |
do_move(GmailApp.getUserLabelByName("[Mailbox]/This Weekend")); | |
} | |
function moveTomorrow() { | |
do_move(GmailApp.getUserLabelByName("[Mailbox]/Tomorrow")); | |
} | |
function moveNextWeek() { | |
do_move(GmailApp.getUserLabelByName("[Mailbox]/Next Week")); | |
} | |
function moveMonth() { | |
do_move(GmailApp.getUserLabelByName("[Mailbox]/Next Month")); | |
} | |
function moveEvenings() { | |
do_move(GmailApp.getUserLabelByName("[Mailbox]/This Evening")); | |
} | |
function moveWednesday() { | |
do_move(GmailApp.getUserLabelByName("[Mailbox]/Wednesday")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
forked from http://dpeck.net/posts/2014/09/give-gmail-mailbox-style-snooze-functionality-right-now-no-extension-required/