Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@hokaccha
Created February 5, 2009 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hokaccha/58601 to your computer and use it in GitHub Desktop.
Save hokaccha/58601 to your computer and use it in GitHub Desktop.
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