编程语言
首页 > 编程语言> > javascript – 如何在GitHub上分享我自己的要点?

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

作者:互联网

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

一种可能性:在gist上发布了一个脚本,但我不知道如何在我的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.

解决方法:

试试Fork your own Gist小书签.

它为您自己的Gist添加了一个功能齐全的Fork按钮.

如果页面中已存在Fork按钮,则此bookmarklet将焦点设置为它而不是添加另一个.

更改是暂时的,只要您离开该Gist,按钮就会消失(单击Fork按钮也会为您执行此操作).

标签:javascript,github,gist
来源: https://codeday.me/bug/20190629/1328806.html