我的代码tampermonkey google chrome

时间:2016-03-23 16:28:46

标签: github

我想添加一个按钮,从文件的原始文件转到Github源页面,这里是代码:



// ==UserScript==
// @name        From Raw To Github
// @namespace   From Raw To Github
// @description Add a button to go to Github source page from the raw of a file
// @include     https://raw.githubusercontent.com/*
// @version     1
// @grant       none
// ==/UserScript==

var rawURL = window.location.href;
var [_, repo, path] = rawURL.match(/https?:\/\/raw\.githubusercontent\.com\/([^\/]+\/[^\/]+)\/(.+)\/.+/);

var a = document.createElement("a");
a.href = "https://github.com/" + repo + "/tree/" + path;

var button = document.createElement("button");
button.innerHTML = "Go to Github folder";

a.appendChild(button);

document.body.insertBefore(a, document.body.firstChild);

  




这是错误:

enter image description here

出了什么问题?

0 个答案:

没有答案