Skip to content

Instantly share code, notes, and snippets.

@jpwatts
Created May 30, 2010 02:24
Show Gist options
  • Select an option

  • Save jpwatts/418716 to your computer and use it in GitHub Desktop.

Select an option

Save jpwatts/418716 to your computer and use it in GitHub Desktop.

Revisions

  1. jpwatts revised this gist Jun 5, 2010. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions shorturl.js
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,12 @@
    // javascript:(function(){var l=(document.querySelector('[rev~="canonical"]')||document.querySelector('[rel~="alternate"][rel~="short"]')||document.querySelector('[rel~="shortlink"]')||document.querySelector('[rel~="shorturl"]')||document.querySelector('[rel~="alternate"][rel~="shorter"]'));if(l){prompt("Short URL:",l.href);}else{window.shortUrlBookmarkletCallback=function(bitly){if(bitly.status_code===200){prompt("Bit.ly URL:",bitly.data.url);}else{alert("Bit.ly error:"+bitly.status_txt);}};var s=document.createElement('script');s.type='text/javascript';s.src=('http://api.bit.ly/v3/shorten'+'?longURL='+encodeURIComponent(window.location.href)+'&domain=j.mp'+'&format=json'+'&callback=shortUrlBookmarkletCallback'+'&login=BITLY_USERNAME'+'&apiKey=BITLY_API_KEY');document.querySelector('head').appendChild(s);}})();
    // javascript:(function(){var l=(document.querySelector('[rev~="canonical"]')||document.querySelector('[rel~="alternate"][rel~="short"]')||document.querySelector('[rel~="shortlink"]')||document.querySelector('[rel~="shorturl"]')||document.querySelector('[rel~="alternate"][rel~="shorter"]'));if(l){prompt("Short URL:",l.getAttribute('href'));}else{window.shortUrlBookmarkletCallback=function(bitly){if(bitly.status_code===200){prompt("Bit.ly URL:",bitly.data.url);}else{alert("Bit.ly error:"+bitly.status_txt);}};var s=document.createElement('script');s.type='text/javascript';s.src=('http://api.bit.ly/v3/shorten'+'?longURL='+encodeURIComponent(window.location.href)+'&domain=j.mp'+'&format=json'+'&callback=shortUrlBookmarkletCallback'+'&login=BITLY_USERNAME'+'&apiKey=BITLY_API_KEY');document.querySelector('head').appendChild(s);}})();
    (function() {
    var l = (document.querySelector('[rev~="canonical"]')
    || document.querySelector('[rel~="alternate"][rel~="short"]')
    || document.querySelector('[rel~="shortlink"]')
    || document.querySelector('[rel~="shorturl"]')
    || document.querySelector('[rel~="alternate"][rel~="shorter"]'));
    if (l) {
    prompt("Short URL:", l.href);
    prompt("Short URL:", l.getAttribute('href'));
    } else {
    window.shortUrlBookmarkletCallback = function(bitly) {
    if (bitly.status_code === 200) {
  2. jpwatts revised this gist Jun 5, 2010. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion shorturl.js
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,9 @@
    // javascript:(function(){var l=(document.querySelector('[rev~="canonical"]')||document.querySelector('[rel~="alternate"][rel~="short"]')||document.querySelector('[rel~="shortlink"]')||document.querySelector('[rel~="alternate"][rel~="shorter"]'));if(l){prompt("Short URL:",l.href);}else{window.shortUrlBookmarkletCallback=function(bitly){if(bitly.status_code===200){prompt("Bit.ly URL:",bitly.data.url);}else{alert("Bit.ly error:"+bitly.status_txt);}};var s=document.createElement('script');s.type='text/javascript';s.src=('http://api.bit.ly/v3/shorten'+'?longURL='+encodeURIComponent(window.location.href)+'&domain=j.mp'+'&format=json'+'&callback=shortUrlBookmarkletCallback'+'&login=BITLY_USERNAME'+'&apiKey=BITLY_API_KEY');document.querySelector('head').appendChild(s);}})();
    // javascript:(function(){var l=(document.querySelector('[rev~="canonical"]')||document.querySelector('[rel~="alternate"][rel~="short"]')||document.querySelector('[rel~="shortlink"]')||document.querySelector('[rel~="shorturl"]')||document.querySelector('[rel~="alternate"][rel~="shorter"]'));if(l){prompt("Short URL:",l.href);}else{window.shortUrlBookmarkletCallback=function(bitly){if(bitly.status_code===200){prompt("Bit.ly URL:",bitly.data.url);}else{alert("Bit.ly error:"+bitly.status_txt);}};var s=document.createElement('script');s.type='text/javascript';s.src=('http://api.bit.ly/v3/shorten'+'?longURL='+encodeURIComponent(window.location.href)+'&domain=j.mp'+'&format=json'+'&callback=shortUrlBookmarkletCallback'+'&login=BITLY_USERNAME'+'&apiKey=BITLY_API_KEY');document.querySelector('head').appendChild(s);}})();
    (function() {
    var l = (document.querySelector('[rev~="canonical"]')
    || document.querySelector('[rel~="alternate"][rel~="short"]')
    || document.querySelector('[rel~="shortlink"]')
    || document.querySelector('[rel~="shorturl"]')
    || document.querySelector('[rel~="alternate"][rel~="shorter"]'));
    if (l) {
    prompt("Short URL:", l.href);
  3. jpwatts revised this gist May 30, 2010. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions shorturl.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    // javascript:(function(){var l=(document.querySelector('[rev~="canonical"]')||document.querySelector('[rel~="alternate"][rel~="short"]')||document.querySelector('[rel~="shortlink"]')||document.querySelector('[rel~="alternate"][rel~="shorter"]'));if(l){prompt("Short URL:",l.href);}else{window.shortUrlBookmarkletCallback=function(bitly){if(bitly.status_code===200){prompt("Bit.ly URL:",bitly.data.url);}else{alert("Bit.ly error:"+bitly.status_txt);}};var s=document.createElement('script');s.type='text/javascript';s.src=('http://api.bit.ly/v3/shorten'+'?longURL='+encodeURIComponent(window.location.href)+'&domain=j.mp'+'&format=json'+'&callback=shortUrlBookmarkletCallback'+'&login=BITLY_USERNAME'+'&apiKey=BITLY_API_KEY');document.querySelector('head').appendChild(s);}})();
    (function() {
    var l = (document.querySelector('[rev~="canonical"]')
    || document.querySelector('[rel~="alternate"][rel~="short"]')
  4. jpwatts renamed this gist May 30, 2010. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. jpwatts created this gist May 30, 2010.
    27 changes: 27 additions & 0 deletions Short URL Bookmarklet
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    (function() {
    var l = (document.querySelector('[rev~="canonical"]')
    || document.querySelector('[rel~="alternate"][rel~="short"]')
    || document.querySelector('[rel~="shortlink"]')
    || document.querySelector('[rel~="alternate"][rel~="shorter"]'));
    if (l) {
    prompt("Short URL:", l.href);
    } else {
    window.shortUrlBookmarkletCallback = function(bitly) {
    if (bitly.status_code === 200) {
    prompt("Bit.ly URL:", bitly.data.url);
    } else {
    alert("Bit.ly error: " + bitly.status_txt);
    }
    };
    var s = document.createElement('script');
    s.type = 'text/javascript';
    s.src = ('http://api.bit.ly/v3/shorten'
    + '?longURL=' + encodeURIComponent(window.location.href)
    + '&domain=j.mp'
    + '&format=json'
    + '&callback=shortUrlBookmarkletCallback'
    + '&login=BITLY_USERNAME'
    + '&apiKey=BITLY_API_KEY');
    document.querySelector('head').appendChild(s);
    }
    })();