BearPanther.com

GoToRepo Bookmarklet

Introduction

user

bear


LATEST POSTS

Using jsformat with Sublime Text 26th July, 2014

There are many d3 demos like this but this one is mine 08th June, 2014

Blog

GoToRepo Bookmarklet

Posted on .

Earlier this week I was looking at something on github.io and wanted to see the associated repository. There wasn’t a link on the page so I started to do the github-pages-to-repo-shuffle. That is:

  • change .io to .com
  • move subdomain (github user name) after .com/
  • trim everything after the repo name

While tweaking the URL, I had a “there’s got a be a better way” moment followed by “I know JavaScript so let’s automate this”. Here’s what I came up with:

(function() {
  var w = window.location;
  window.location = "https://github.com/"+ 
    w.hostname.split(".")[0] + "/" + 
    w.pathname.split("/")[1];
})();

It looks trival when put that way but I think this will be a time saver for me in the future. Here it is as a gist on a single line.

Toss that in a bookmark(let) on your bookmarks bar and say goodbye to manually editing github pages URLs to go to github repos.

Comments
user

Author Praveen

Posted at 8:51 pm December 11, 2013.

Thanks!

Reply
user

Author Chloe

Posted at 7:21 pm September 12, 2016.

If you are interested in topic: earn your stripes origin – you should read about Bucksflooder first

Reply

Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

View Comments (2) ...