Skip to content

Instantly share code, notes, and snippets.

@paazmaya
Last active December 4, 2024 08:53
Show Gist options
  • Save paazmaya/97fbd2b487951bb6cbccc7ecdcc4dc13 to your computer and use it in GitHub Desktop.
Save paazmaya/97fbd2b487951bb6cbccc7ecdcc4dc13 to your computer and use it in GitHub Desktop.
Get git clone commands from Gitlab repositories in your own profile page
// Copy these to the browser console. Using let instead of const to allow reassinging when its sometimes needed.
// Get a list of GitLab project URLs from a page
let list = document.querySelectorAll('.project-details h2 a');
let urls = Array.from(list).map(item => item.getAttribute('href'));
// Remove the leading / from the URLs and combine with SSH git URL
let ssh_git_urls = urls.map(item => item.replace(/^\//, '')).map(item => `[email protected]:${item}.git`);
// Add clone command to the URLs
ssh_git_urls.forEach(item => console.log(`git clone ${item}`));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment