Skip to content

Instantly share code, notes, and snippets.

@elijahmanor
Created July 2, 2011 19:03
Show Gist options
  • Save elijahmanor/1061534 to your computer and use it in GitHub Desktop.
Save elijahmanor/1061534 to your computer and use it in GitHub Desktop.
Toggle JS Bin & Gist
//http://userjs.up.seesaa.net/js/bookmarklet.html
(function() {
var location = document.location.href,
newLocation = null;
if ( ~location.indexOf( "gist.github.com" ) ) {
console.log( "Switching from gist to jsbin..." );
newLocation = location.replace( /https:\/\/gist.github.com\/(\d+)/, function( str, group1 ) {
return "http://jsbin.com/gist/" + group1;
});
} else if ( ~location.indexOf( "jsbin.com" ) ) {
console.log( "Switching from jsbin to gist..." );
newLocation = location.replace( /http:\/\/jsbin.com\/gist\/(\d+)/, function( str, group1 ) {
return "https://gist.github.com/" + group1;
});
} else {
console.log( "Nothing to do..." );
}
if ( newLocation ) {
document.location.href = newLocation;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment