I want to create a fat monkey monkey script that will add a shortcut to the action of logging out to one email site.
There is currently an exit link for "logout & hl = en" , which has id = ": r5" . I can get the node for the link, but I canβt call, click on it.
I tried the script as below
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 that does not work. What do you think is wrong here?
Thanks J
javascript javascript-events greasemonkey hyperlink
Jijoy
source share