Skip to content

Instantly share code, notes, and snippets.

@abernier
Last active October 11, 2023 11:03
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save abernier/3227047 to your computer and use it in GitHub Desktop.
Save abernier/3227047 to your computer and use it in GitHub Desktop.
Clone gist in Desktop

Download the user.js file and then drop it into your chrome://extensions/ tab and enjoy the Clone in Desktop button on your gists!

// ==UserScript==
// @id clonegistindesktop
// @name Clone gist in Desktop
// @author Antoine BERNIER (abernier)
// @version 0.0.2
// @description Add a 'Clone in Desktop' button to gists
// @match https://gist.github.com/*
// ==/UserScript==
(function () {
var li = document.createElement('li');
var downloadLi = document.querySelector('a[href*="/download"]').parentNode;
var repoUrl = document.querySelector('input[name="url-field"]').getAttribute('value');
// make a copy of the download li
li.innerHTML = downloadLi.innerHTML;
// Change some things
li.innerHTML = li.innerHTML.replace(/href="[^"]*"/, 'href="github-mac://openRepo/' + repoUrl + '"');
li.innerHTML = li.innerHTML.replace('Download Gist', 'Clone in Desktop');
li.innerHTML = li.innerHTML.replace('octicon-cloud-download', 'octicon-device-desktop');
// insert just before
downloadLi.parentNode.insertBefore(li, downloadLi);
}());
@abernier
Copy link
Author

abernier commented Feb 3, 2014

Just updated so it now re-works for new gists interface ;)

@Dyndrilliac
Copy link

Can you add this to the Chrome web store? Even with developer mode enabled, the stable branch of Chrome for Windows only allows extensions that come from the Chrome web store. I wish GitHub would make add this feature to Gist pages, but until then this seems to be the only avenue for cloning Gists using the GitHub desktop on Windows. Cloning manually from the command-line is lame!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment