Skip to content

Instantly share code, notes, and snippets.

@wesmaldonado
Created March 10, 2009 23:43
Show Gist options
  • Save wesmaldonado/77207 to your computer and use it in GitHub Desktop.
Save wesmaldonado/77207 to your computer and use it in GitHub Desktop.
Bookmarklet to find any links with tinyurl.com in their name... good for finding random links to click by searching twitter for "tinyurl" then clicking this bookmarklet. Made for my friend Dan who obviously can't waste enough of his time through standard
javascript:(function(){var%20x,n,nD,z,i;%20function%20htmlEscape(s){s=s.replace(/&/g,'&amp;');s=s.replace(/>/g,'&gt;');s=s.replace(/</g,'&lt;');return%20s;}%20function%20attrQuoteEscape(s){s=s.replace(/&/g,'&amp;');%20s=s.replace(/"/g,%20'&quot;');return%20s;}%20x="tinyurl.com";%20n=0;%20if(x!=null)%20{%20x=x.toLowerCase();%20nD%20=%20window.open().document;%20nD.writeln('<html><head><title>Links%20containing%20"'+htmlEscape(x)+'"</title><base%20target="_blank"></head><body>');%20nD.writeln('Links%20on%20<a%20href="'+attrQuoteEscape(location.href)+'">'+htmlEscape(location.href)+'</a><br>%20with%20link%20text%20or%20target%20url%20containing%20&quot;'%20+%20htmlEscape(x)%20+%20'&quot;<br><hr>');%20z%20=%20document.links;%20for%20(i%20=%200;%20i%20<%20z.length;%20++i)%20{%20if%20((z[i].innerHTML%20&&%20z[i].innerHTML.toLowerCase().indexOf(x)%20!=%20-1)%20||%20z[i].href.toLowerCase().indexOf(x)%20!=%20-1%20)%20{%20nD.writeln(++n%20+%20'.%20<a%20href="'%20+%20attrQuoteEscape(z[i].href)%20+%20'">'%20+%20(z[i].innerHTML%20||%20htmlEscape(z[i].href))%20+%20'</a><br>');%20}%20}%20nD.writeln('<hr></body></html>');%20nD.close();%20}%20})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment