Tips:
- http://ozh.org/text/ various text utilities, for instance to unescape a bookmarklet
- http://jsbeautifier.org/ to prettify and make readable
- http://ted.mielczarek.org/code/mozilla/bookmarklet.html to crunch back into a bookmarklet
| // Share on Facebook | |
| var d = document, | |
| enc = encodeURIComponent, | |
| share = 'facebook', | |
| f = 'http://sho.rt/admin/index.php', | |
| l=d.location.href, | |
| ups=l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0]; | |
| var ur=l.split(new RegExp(ups))[1]; | |
| var ups=ups.split(/\:/); | |
| p = '?up=' + enc(ups[0]+':') + '&us=' + enc(ups[1]) + '&ur=' + enc(ur) + '&t=' + enc(d.title) + '&share=' + share, | |
| u = f + p; | |
| try { | |
| throw ('ozhismygod'); | |
| } catch (z) { | |
| a = function () { | |
| if (!window.open(u,'Share','width=500,height=340,left=100','_blank')) l.href = u; | |
| }; | |
| if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); | |
| else a(); | |
| } | |
| void(0); |
| // Share on Twitter | |
| var d = document, | |
| w = window, | |
| enc = encodeURIComponent, | |
| share = 'twitter', | |
| e = w.getSelection, | |
| k = d.getSelection, | |
| x = d.selection, | |
| s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)), | |
| s2 = ((s.toString() == '') ? s : '%20%22' + enc(s) + '%22'), | |
| f = 'http://sho.rt/admin/index.php', | |
| l = d.location.href, | |
| ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0], | |
| ur = l.split(new RegExp(ups))[1], | |
| ups = ups.split(/\:/), | |
| p = '?up=' + enc(ups[0]+':') + '&us=' + enc(ups[1]) + '&ur='+enc(ur) + '&t=' + enc(d.title) + s2 + '&share=' + share, | |
| u = f + p; | |
| try { | |
| throw ('ozhismygod'); | |
| } catch (z) { | |
| a = function () { | |
| if (!w.open(u,'Share','width=780,height=265,left=100','_blank')) l = u; | |
| }; | |
| if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); | |
| else a(); | |
| } | |
| void(0); |
| // Simple Standard (new page) | |
| var d = document, | |
| w = window, | |
| enc = encodeURIComponent, | |
| e = w.getSelection, | |
| k = d.getSelection, | |
| x = d.selection, | |
| s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)), | |
| s2 = ((s.toString() == '') ? s : enc(s)), | |
| f = 'http://sho.rt/admin/index.php', | |
| l = d.location.href, | |
| ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0], | |
| ur = l.split(new RegExp(ups))[1], | |
| ups = ups.split(/\:/), | |
| p = '?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title)+'&s='+s2, | |
| u = f + p; | |
| try { | |
| throw ('ozhismygod'); | |
| } catch (z) { | |
| a = function () { | |
| if (!w.open(u)) l.href = u; | |
| }; | |
| if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); | |
| else a(); | |
| } | |
| void(0); |
| // Simple Popup (in-page popup dialog) | |
| var d = document, | |
| w = window, | |
| sc = d.createElement('script'), | |
| l = d.location.href, | |
| enc = encodeURIComponent, | |
| ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0], | |
| ur = l.split(new RegExp(ups))[1], | |
| ups = ups.split(/\:/), | |
| p = '?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title); | |
| w.yourls_callback = function (r) { | |
| if (r.short_url) { | |
| prompt(r.message, r.short_url); | |
| } else { | |
| alert('An error occured: ' + r.message); | |
| } | |
| }; | |
| sc.src = 'http://sho.rt/admin/index.php' + p + '&jsonp=yourls'; | |
| void(d.body.appendChild(sc)); |
| // Custom Standard (prompt for a keyword) | |
| var d = document, | |
| enc = encodeURIComponent, | |
| e = window.getSelection, | |
| k = d.getSelection, | |
| x = d.selection, | |
| s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)), | |
| s2 = ((s.toString() == '') ? s : enc(s)), | |
| f = 'http://sho.rt/admin/index.php', | |
| l = d.location.href, | |
| ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0], | |
| ur = l.split(new RegExp(ups))[1], | |
| ups = ups.split(/\:/), | |
| k = prompt("Custom URL"), | |
| k2 = (k ? '&k=' + k : ""), | |
| p = '?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title)+'&s='+s2 + k2, | |
| u = f + p; | |
| if (k != null) { | |
| try { | |
| throw ('ozhismygod'); | |
| } catch (z) { | |
| a = function () { | |
| if (!w.open(u)) l = u; | |
| }; | |
| if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); | |
| else a(); | |
| } | |
| void(0) | |
| } |
| // Custom Popup (prompt for a keyword + on-page popup) | |
| var d = document, | |
| l = d.location.href, | |
| k = prompt('Custom URL'), | |
| enc = encodeURIComponent, | |
| ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0], | |
| ur = l.split(new RegExp(ups))[1], | |
| ups = ups.split(/\:/), | |
| p = '?up='+enc(ups[0]+':')+'&us='+enc(ups[1])+'&ur='+enc(ur)+'&t='+enc(d.title); | |
| sc = d.createElement('script'); | |
| if (k != null) { | |
| window.yourls_callback = function (r) { | |
| if (r.short_url) { | |
| prompt(r.message, r.short_url); | |
| } else { | |
| alert('An error occured: ' + r.message); | |
| } | |
| }; | |
| sc.src = 'http://sho.rt/admin/index.php' + p + '&k=' + k + '&jsonp=yourls'; | |
| void(d.body.appendChild(sc)); | |
| } |
| // Share on Tumlr | |
| var d = document, | |
| w = window, | |
| enc = encodeURIComponent, | |
| share = 'tumblr', | |
| e = w.getSelection, | |
| k = d.getSelection, | |
| x = d.selection, | |
| s = (e ? e() : (k) ? k() : (x ? x.createRange().text : 0)), | |
| s2 = ((s.toString() == '') ? s : '%20%22' + enc(s) + '%22'), | |
| f = 'http://sho.rt/admin/index.php', | |
| l = d.location.href, | |
| ups = l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0], | |
| ur = l.split(new RegExp(ups))[1], | |
| ups = ups.split(/\:/), | |
| p = '?up=' + enc(ups[0]+':') + '&us=' + enc(ups[1]) + '&ur='+enc(ur) + '&t=' + enc(d.title) + '&s=' + s2 + '&share=' + share, | |
| u = f + p; | |
| try { | |
| throw ('ozhismygod'); | |
| } catch (z) { | |
| a = function () { | |
| if (!w.open(u,'Share','width=450,height=450,left=430','_blank')) l = u; | |
| }; | |
| if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); | |
| else a(); | |
| } | |
| void(0); |
Tips: