Want to fork your own gists? No fork button? No problem! Install this user script by clicking refork.user.js' "raw" link down below: ⇓
-
-
Save enjalot/3375156 to your computer and use it in GitHub Desktop.
(Re)fork any gist, including your own
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name (Re)fork any gist, including your own | |
// @namespace https://github.com/johan | |
// @description Adds a "fork" button to gists missing one at gist.github.com, so you can create multiple forks | |
// @match https://gist.github.com/* | |
// @include https://gist.github.com/* | |
// ==/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'; | |
a.style.cssText = 'float: right; margin: 4px 7px 0'; | |
a.addEventListener('click', fork); | |
a.appendChild(i); | |
i.alt = 'fork'; | |
i.src = u.replace(/[^\/]*$/, 'fork_button.png'); | |
i.className = 'button'; | |
p.appendChild(a); | |
} | |
function fork(e) { | |
var f = document.body.appendChild(document.createElement('form')); | |
f.method = 'POST'; | |
f.action = '/fork' + location.pathname; | |
f.appendChild(document.querySelector('input[name=authenticity_token]')); | |
f.submit(); | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment