Skip to content

Instantly share code, notes, and snippets.

@simonsan
Created November 26, 2024 07:51
Show Gist options
  • Save simonsan/59e4b46f69b3b9f5d3cfcb166d937bad to your computer and use it in GitHub Desktop.
Save simonsan/59e4b46f69b3b9f5d3cfcb166d937bad to your computer and use it in GitHub Desktop.
Github Repository Transfer Bookmarklet
javascript:(function(){const currentUrl=window.location.href;const match=currentUrl.match(/^https:\/\/github\.com\/([^\/]+)\/([^\/]+)(\/|$)/);if(match&&match.length>=3){const username=match[1];const repository=match[2];const userRepo=`${username}/${repository}`;navigator.clipboard.writeText(userRepo).then(function(){if(!currentUrl.endsWith('/transfer')){window.location.href=currentUrl.replace(/\/$/,'')+'/transfer';}}).catch(function(err){alert('Failed to copy to clipboard');});}else{alert('This bookmarklet only works on GitHub repository pages.');}})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment