4

自分のGitHubの要点をフォークするにはどうすればよいですか?

1つの可能性:要点に投稿されたスクリプトがありますが、それをgitHubにインストールする方法がわかりません。その場合、スクリプトの使用方法とその機能について説明します。

(再)あなた自身を含むあらゆる要点をフォークする

<!-- 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リポジトリをフォークする方法を示しています。

4

1 に答える 1