Last active
August 29, 2015 13:57
-
-
Save akaleeroy/9774634 to your computer and use it in GitHub Desktop.
Pretty Link Bookmarklet
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
// TODO: Switch to CSS, #prettylink:active { cursor: -webkit-grabbing; } | |
// TODO: Deliver [Esc] from conflicts | |
javascript: (function() { | |
var a = document.createElement('a'); | |
a.title = document.domain; | |
if (document.title) { | |
a.innerHTML = document.title; | |
} else { | |
a.innerHTML = prompt("This page has no title. What should the link text say?"); | |
} | |
a.href = document.location.href; | |
a.setAttribute('style', 'position: fixed; z-index: 9999999999; text-align: center; background: #fff; max-width: 420px; margin: 10px auto; left: 0; right: 0; padding: .4em 1em; border-radius: 4px; border: 1px solid; box-shadow: 0px 1px 30px rgba(0,0,0,.4), 0px 3px 0px rgba(0,0,0,0.1); cursor: -webkit-grab;'); | |
document.body.parentNode.insertBefore(a, document.body); | |
a.onclick = function(e) { | |
return false; | |
}; | |
window.onkeydown = function(e) { | |
if (e.keyCode == 27) { | |
a.parentNode.removeChild(a); | |
} | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment