Created
March 11, 2014 16:10
-
-
Save spiralx/9489034 to your computer and use it in GitHub Desktop.
Bookmarklets I've written or found useful
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
/* | |
* Prompts for the URL of a script, then creates a bookmarklet to load and run the script. | |
* | |
* javascript:(function(u) {u=prompt('Script URL');u&&prompt('Bookmarklet', 'javascript:(function(d,s){s=d.createElement("script");s.src="'+u.replace(/^https?:/,'')+'?cb="+Math.random();d.body.appendChild(s)})(document)') })() | |
*/ | |
(function(u) { | |
u = prompt('Script URL'); | |
u && prompt('Bookmarklet', | |
'javascript:(function(d,s){s=d.createElement("script");s.src="' + | |
u.replace(/^https?:/,'') + | |
'?cb="+Math.random();d.body.appendChild(s)})(document)') | |
})() | |
/* | |
* Same, but shows a element at the top of the page with a link you can drag to your bookmarks. | |
* | |
* javascript:(function(d, u, b, a){u=prompt('Script URL');if(u){b='javascript:(function(d,s){s=d.createElement("script");s.src="'+u.replace(/^https?:/,'')+'?cb="+Math.random();d.body.appendChild(s)})(document)';a = d.createElement('a');a.setAttribute('style','display:block;position:fixed;top:10px;width:640px;left:50%;margin-left:-320px;border:solid 2px black;padding:6px;font-weight:bold;background:#fff');a.href = a.textContent = b;d.body.appendChild(a)}})(document) | |
*/ | |
(function(d, u, b, a) { | |
u = prompt('Script URL'); | |
if (u) { | |
b = 'javascript:(function(d,s){s=d.createElement("script");s.src="' + | |
u.replace(/^https?:/,'') + | |
'?cb="+Math.random();d.body.appendChild(s)})(document)'; | |
a = d.createElement('a'); | |
a.setAttribute('style', 'display:block;position:fixed;top:10px;width:640px;left:50%;margin-left:-320px;border:solid 2px black;padding:6px;font-weight:bold;background:#fff'); | |
a.href = a.textContent = b; | |
d.body.appendChild(a) | |
} | |
})(document) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment