Useful Bookmarklet for GitHub

Hi all!

I use GitHub with Binder quite frequently, and often want to launch a repo on MyBinder.org. In particular, I find Gists to be a very quick way to prepare a shared JupyterLab resource.

This simple bookmarklet constructs the URLs to open Gists and repositories on MyBinder (assuming HEAD revision).

javascript:(function()%7B(function%20_()%7Bconsole.log(window.location)%3Bdest%20%3D%20new%20URL(%22https%3A%2F%2Fmybinder.org%22)%3Bif%20(window.location.host%20%3D%3D%3D%20%22gist.github.com%22)%7Bdest.pathname%20%3D%20%60%2Fv2%2Fgist%24%7Bwindow.location.pathname%7D%60%3B%7Delse%20if%20(window.location.host%20%3D%3D%3D%20%22github.com%22)%7Bdest.pathname%20%3D%20%60%2Fv2%2Fgh%24%7Bwindow.location.pathname%7D%2FHEAD%60%3B%7D%20else%20%7Breturn%3B%7Dwindow.open(dest)%7D)()%7D)()

You can paste the source into URL Decoder/Encoder if you wish to ensure the safety of the code!