-
-
Save pdokas/675469 to your computer and use it in GitHub Desktop.
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
javascript:%20(function(){var%20a=document.getElementsByTagName('script'),i,l,result,rurl=/^http:\/\/use\.typekit\.com\/([0-9A-Za-z]+)\.js/;for(i=0,l=a.length-1;i<l;i++){if(result=rurl.exec(a[i].getAttribute('src'))){window.location.assign('http://typekit.com/colophons/'+result[1]);break;}}%20if(!result){alert('This%20site%20doesn\'t%20use%20Typekit!');}})(); |
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
(function() { | |
var a = document.getElementsByTagName('script'), | |
i, l, result, | |
rurl = /^http:\/\/use\.typekit\.com\/([0-9A-Za-z]+)\.js/; | |
for (i = 0, l = a.length - 1; i < l; i++) { | |
if (result = rurl.exec(a[i].getAttribute('src'))) { | |
window.location.assign('http://typekit.com/colophons/' + result[1]); | |
break; | |
} | |
} | |
if (!result) { | |
alert('This site doesn\'t use Typekit!'); | |
} | |
})(); |
Awesome! I'm definitely going to replace my code with yours. Works great!
This is also why I posted it as a gist. I knew someone who had a better-than-hacky knowledge of JS would write something better.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A few improvements:
src
ofscript
s.script
NodeList since that's an expensive recalculation on the live DOM every time through.