Created
January 11, 2011 21:03
-
-
Save banterability/775137 to your computer and use it in GitHub Desktop.
Bookmarklet to switch between GitHub code & documentation in GitHub pages
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
h = location.href | |
docStr = /^http:\/\/(\w*).github.com\/(\w*)(?:\/.*)?/ | |
codeStr = /^https?:\/\/github.com\/(\w*)\/(\w*)(?:\/.*)?/ | |
docTmp = "http://$user.github.com/$proj" | |
codeTmp = "https://github.com/$user/$proj" | |
isDoc = h.match(docStr) | |
isCode = h.match(codeStr) | |
redirect = (loc) -> | |
location.href = loc | |
true | |
if isDoc | |
user = isDoc[1] | |
proj = isDoc[2] | |
redirect(codeTmp.replace("$user", user).replace("$proj", proj)) | |
else if isCode | |
user = isCode[1] | |
proj = isCode[2] | |
redirect(docTmp.replace("$user", user).replace("$proj", proj)) | |
else | |
false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment