Created
January 14, 2009 08:10
-
-
Save satyr/46836 to your computer and use it in GitHub Desktop.
Allows accessing Bookmark Toolbar with alt/opt + 1~0.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name BookmarKeys | |
// @namespace http://d.hatena.ne.jp/murky-satyr | |
// @description Allows accessing Bookmark Toolbar with alt/opt + 1~0. | |
// @include main | |
// @compatibility Firefox 3.0+ | |
// @author satyr | |
// @version 09-12-01 | |
// @note inspired by addons.mozilla.org/en-US/firefox/addon/3647 | |
// ==/UserScript== | |
function bookmarKey(n){ | |
var bb = document.getElementById('bookmarksBarContent'); | |
var lm = n ? bb.childNodes[n-1] : bb.lastChild; | |
if(!lm) return; | |
var mp = lm.firstChild; | |
if(mp) mp.showPopup(); | |
else { | |
lm.click(); | |
lm.disabled = true; | |
setTimeout(function(){ lm.disabled = false }, 333); | |
} | |
} | |
for(let ks = document.getElementById('mainKeyset'), i = 0; i <= 9; ++i){ | |
let k = ks.appendChild(document.createElement('key')); | |
k.setAttribute('id', 'BookmarKey'+ i); | |
k.setAttribute('oncommand', 'bookmarKey('+ i +')'); | |
k.setAttribute('modifiers', 'alt'); | |
k.setAttribute('key', i); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment