Skip to content

Instantly share code, notes, and snippets.

@hokaccha hokaccha/gist:58601
Created Feb 5, 2009

Embed
What would you like to do?
gmailUnread user script
// ==UserScript==
// @name gmailUnread
// @namespace http://webtech-walker.com/
// @author hokaccha (Kazuhito Hokamura)
// @include http://mail.google.com/*
// @description add shortcut key is:unread search query
// ==/UserScript==
(function(){
document.addEventListener('keypress', function(e){
var s = document.getElementById(":ra");
if(!s) return;
//default key code is <C-/>
var key = 47;
var key_win = 63;
var is_win = (navigator.userAgent.indexOf("Win") != -1);
if((e.charCode == key && e.ctrlKey) || (is_win && e.shiftKey && e.ctrlKey && e.charCode == key_win)) {
if(e.shiftKey) {
if(s.value.indexOf('is:unread') == -1) {
s.value += " is:unread";
}
} else {
s.value = "is:unread"
}
s.focus();
}
}, true);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.