-
-
Save rwilkes/a17af6e5782705ae6d830c3ef32037ce to your computer and use it in GitHub Desktop.
bookmark-launcher.user.js (chrome)
This file contains hidden or 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 Bookmark Launcher | |
// @description Launches bookmakrs with keyboard shortcuts | |
// ==/UserScript== | |
var bookmarkLauncherSetup = (function() { | |
var bookmarks = {}, url; | |
bookmarks['D'] = function(e,t){var n=e.document;setTimeout(function(){function a(e){if(e.data==="destroy_bookmarklet"){var r=n.getElementById(t);if(r){n.body.removeChild(r);r=null}}}var t="DELI_bookmarklet_iframe",r=n.getElementById(t);if(r){return}var i="https://delicious.com/save?source=bookmarklet&",s=n.createElement("iframe");s.id=t;s.src=i+"url="+encodeURIComponent(e.location.href)+"&title="+encodeURIComponent(n.title)+"¬e="+encodeURIComponent(""+(e.getSelection?e.getSelection():n.getSelection?n.getSelection():n.selection.createRange().text))+"&v=1.1";s.style.position="fixed";s.style.top="0";s.style.left="0";s.style.height="100%";s.style.width="100%";s.style.zIndex="16777270";s.style.border="none";s.style.visibility="hidden";s.onload=function(){this.style.visibility="visible"};n.body.appendChild(s);var o=e.addEventListener?"addEventListener":"attachEvent";var u=o=="attachEvent"?"onmessage":"message";e[o](u,a,false)},1)}; | |
bookmarks['S'] = 'http://superuser.com'; | |
window.addEventListener('keyup', function() { | |
if(event.ctrlKey && event.altKey && !event.shiftKey) | |
{ | |
url = bookmarks[String.fromCharCode(event.keyCode)]; | |
switch (typeof url) | |
{ | |
case "string": | |
return window.open(url); | |
case "function": | |
return url(window); | |
} | |
} | |
}); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment