From 4af061f2fe2df527a8f7ceb93ddf10e2a50c138c Mon Sep 17 00:00:00 2001 From: Fabien Benetou Date: Fri, 17 Jun 2011 10:26:14 +0200 Subject: [PATCH] GM revertedpim script interface improvements --- pub/code/reverted_pim_links.user.js | 39 ++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/pub/code/reverted_pim_links.user.js b/pub/code/reverted_pim_links.user.js index 63ca796..95ebd0a 100644 --- a/pub/code/reverted_pim_links.user.js +++ b/pub/code/reverted_pim_links.user.js @@ -66,13 +66,14 @@ if (PIMpages != "fail") +"[e]" +"

"; } - boxcss = 'position:fixed; right:5px; top:5px; background-color:black; z-index:1;'; + boxcss = 'position:fixed; right:5px; top:5px; background-color:black; z-index:1; opacity:0.7;'; boxcss += 'padding:2px; margin:1px;'; boxcss += 'color:blue; font-size:10px; text-align:right;'; boxcss += 'border-width:3px; border-color:gray; border-style:solid;'; myDiv.style.cssText = boxcss; - myDiv.innerHTML += "

RevertedPIMLinks

"; - myDiv.innerHTML += "

>>

"; + myDiv.style.cssText += ' line-height:1px;'; + myDiv.innerHTML += "

RevertedPIMLinks

"; + myDiv.innerHTML += "

>>


"; if (PIMpages_date != "fail") { myDiv.innerHTML += "

(date:"+PIMpages_date+")

"; @@ -84,6 +85,38 @@ if (PIMpages != "fail") myFoldedDiv.innerHTML += "

<<

"; myFoldedDiv.style.cssText = boxcss; myFoldedDiv.style.cssText += "visibility:hidden;"; + myFoldedDiv.style.cssText += "line-height:10px;"; document.body.appendChild(myFoldedDiv); } + +function shortcuts (e){ + switch(e.charCode) + { + case "u".charCodeAt(0) : document.getElementById('GM_PIM_Window').style.visibility='visible';document.getElementById('GM_PIM_Folded_Window').style.visibility='hidden'; break; + case "f".charCodeAt(0) : document.getElementById('GM_PIM_Window').style.visibility='hidden';document.getElementById('GM_PIM_Folded_Window').style.visibility='visible'; break; + } + +}; + +function registerShortcuts() { + window.addEventListener("keypress", shortcuts, true); +}; + +function unregisterShortcuts() { + window.removeEventListener("keypress", shortcuts, true); +}; + +registerShortcuts(); + +$x('//input | //textarea | //select').forEach(registerListener); + +function registerListener(node) { + node.addEventListener("mouseover", function() { + unregisterShortcuts(); + scroll_pause(); }, true); + node.addEventListener("mouseout", function() { + scroll_start (); + registerShortcuts(); + }, true); +}