Last active
March 12, 2020 00:28
-
-
Save mh61503891/f2033f13042de0e1d0e379040ca876e4 to your computer and use it in GitHub Desktop.
Search mails by labels in Inbox - mail.google.com
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
// ==UserScript== | |
// @name Search mails by labels in Inbox - mail.google.com | |
// @namespace https://msyk.hgsn.info/ | |
// @match https://mail.google.com/mail/u/* | |
// @grant GM_registerMenuCommand | |
// @grant GM_getValue | |
// @version 1.0 | |
// @author Masayuki Higashino | |
// ==/UserScript== | |
function label_names_to_search_uri(label_names) { | |
let base_uri = document.location.href.split('/').slice(0, 6).join('/'); | |
let search_query = '((label:inbox) AND (' + label_names.map(label_name => 'label:' + label_name).join(' OR ') + '))'; | |
let target_uri = base_uri + '/#search/' + encodeURIComponent(search_query); | |
return target_uri; | |
} | |
function search_mails_by_labels_in_inbox() { | |
let labels = GM_getValue('labels', []); | |
let uri = label_names_to_search_uri(labels); | |
document.location.href = uri; | |
} | |
GM_registerMenuCommand("Search mails by labels in Inbox", search_mails_by_labels_in_inbox); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment