Javascript 如何在GitHub上表达我自己的观点?

Javascript 如何在GitHub上表达我自己的观点?,javascript,github,gist,Javascript,Github,Gist,我该如何用叉子叉自己的GitHub 一种可能性是:gist上发布了一个脚本,但我不知道如何在我的gitHub上安装它。在这种情况下,需要解释如何使用脚本以及脚本的作用 //==用户脚本== //@name(Re)提供任何要点,包括您自己的 //@名称空间https://github.com/johan //@description为gist.github.com上缺少的gists添加了一个“fork”按钮,因此您可以创建多个fork //@匹配https://gist.github.com/

我该如何用叉子叉自己的GitHub

一种可能性是:gist上发布了一个脚本,但我不知道如何在我的gitHub上安装它。在这种情况下,需要解释如何使用脚本以及脚本的作用


//==用户脚本==
//@name(Re)提供任何要点,包括您自己的
//@名称空间https://github.com/johan
//@description为gist.github.com上缺少的gists添加了一个“fork”按钮,因此您可以创建多个fork
//@匹配https://gist.github.com/*
//@包括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='创建此要点的另一分支';
a、 style.cssText='float:right;margin:4px7px0';
a、 addEventListener(“单击”,分叉);
a、 儿童(一);
i、 alt='fork';
i、 src=u.replace(/[^\/]*$/,'fork_button.png');
i、 className='按钮';
p、 儿童(a);
}
功能叉(e){
var f=document.body.appendChild(document.createElement('form');
f、 方法='POST';
f、 action='/fork'+location.pathname;
f、 appendChild(document.querySelector('input[name=authenticity\u token');
f、 提交();
返回false;
}
StackOverflow展示了如何使用自己的fork

试试bookmarklet

它为您自己的要点添加了一个功能齐全的分叉按钮

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


更改是暂时的,当您离开该要点时,该按钮将立即消失(单击Fork按钮也会为您完成此操作)。

我为您的这个版本提供了Fork,进行了2次修复,并编辑了自述,向firefox用户解释了如何操作。我还用它制作了一个firefox插件()我现在得到一个错误
uncaughttypeerror:$不是答案中bookmarklet的函数。
<!-- 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;
}