2013-02-20 58 views
3

如何分叉我自己的GitHub要点?如何在GitHub上分享我自己的要点?

一种可能性:有一个脚本张贴在要点上,但我不知道如何将它安装在我的gitHub上。在这种情况下,解释如何使用脚本以及它在做什么。

(Re)Fork any gist, including your own

<!-- language: lang-js --> 
// ==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; 
} 

StackOverflow上展示了如何餐桌自己GitHub repository

回答

3

试试Fork your own Gist书签。

它增加了一个功能齐全的按钮到您自己的要点。

如果一个按钮已经在页面中存在,这个书签将设置焦点,而不是添加另一个。

这个改变是暂时的,只要你离开那个Gist,按钮就会消失(点击按钮也是为你做的)。

+1

我分叉了你的这个版本,做了2个修正,并编辑了自述文件,向firefox用户解释如何去做。 [位于这里 - Gist Fork](https://gist.github.com/Noitidart/8794639)。我也做了一个Firefox插件([位于这里 - ghForkable](https://addons.mozilla.org/en-US/firefox/addon/ghforkable/)) – Noitidart 2014-02-16 22:59:45

+0

我现在得到一个错误'Uncaught TypeError: $不是来自答案中小书签的函数。 – 2016-12-14 19:00:57

相关问题