gists/view_github_code_in_vscode.js
2021-02-19 19:36:38 +08:00

27 lines
866 B
JavaScript

// ==UserScript==
// @name View Code in GitHUB
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://github.com/*/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var navi = document.getElementsByClassName('file-navigation')
console.log(navi)
if (navi.length > 0) {
navi = navi[0]
var node = document.createElement('a')
node.className = 'btn btn-primary'
node.style = 'margin-left: 0.5rem'
node.href = "https://github1s.com" + window.location.pathname
node.innerHTML = "View Code"
node.target = "_blank"
// var sep = navi.getElementsByClassName('flex-auto')[0]
// navi.insertBefore(node, sep.nextSibling)
navi.appendChild(node)
}
})();