Hi , I want to create a greasy monkey script , which will add a shortcut key for logout action in one mail site.
Currently the logout link "?logout&hl=en" which have an id=":r5". I am able to get the node for the link but not able to call click on it.
I tried the script as following
function key_event(event){
GM_log("Hello");
GM_log(event.keyCode);
//if(event.keyCode != 112) return;
e=document.getElementById(':r5');
if(!e) {return;}
var evObj = document.createEvent('MouseEvents');
evObj.initMouseEvent(('click'),true,true,window,0,0,0,0,0,false,false,false,false,0,null);
GM_log(e);
e.dispatchEvent(evObj);
}
document.addEventListener("keypress", key_event, true);
But this is not working . What do you think is wrong here ?
Thanks J