Skip to content

Instantly share code, notes, and snippets.

Forked from johan/
Last active Aug 29, 2015
What would you like to do?

Want to fork your own gists? No fork button? No problem! Install this user script by clicking refork.user.js' "raw" link down below: ⇓

// ==UserScript==
// @name (Re)fork any gist, including your own
// @namespace
// @description Adds a "fork" button to gists missing one at, so you can create multiple forks
// @match*
// @include*
// ==/UserScript==
if (/^\/\d+/.test(location.pathname) &&
!document.querySelector('a img[alt="fork"]')) {
var i = document.createElement('img')
, a = document.createElement('a')
, u = document.querySelector('img.button').src
, p = document.querySelector('.title');
a.title = 'Create another fork of this gist'; = 'float: right; margin: 4px 7px 0';
a.addEventListener('click', fork);
i.alt = 'fork';
i.src = u.replace(/[^\/]*$/, 'fork_button.png');
i.className = 'button';
function fork(e) {
var f = document.body.appendChild(document.createElement('form'));
f.method = 'POST';
f.action = '/fork' + location.pathname;
return false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment