Last active
September 6, 2017 09:10
-
-
Save MightyPork/b8a29d85528559a0dd89eeac7f6903da to your computer and use it in GitHub Desktop.
Add back link to network graph in github project nav
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name github network link | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description add back link to network graph on github | |
// @author MightyPork | |
// @match https://github.com/*/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function addNetworkButton() { | |
const rn = document.querySelector('.reponav'); | |
const oldbutt = rn.querySelector('.nwk-butt'); | |
if(oldbutt) rn.removeChild(oldbutt); | |
if (rn) { | |
const butt = document.createElement('a'); | |
butt.href = location.href.replace(/(https:\/\/github.com\/[^/]+\/[^/]+).*/, "$1/network"); | |
butt.innerHTML = '<svg class="octicon octicon-git-branch" height="16" version="1.1" viewBox="0 0 14 16" width="14" aria-hidden="true"><path fill-rule="evenodd" d="M10 5c0-1.11-.89-2-2-2a1.993 1.993 0 0 0-1 3.72v.3c-.02.52-.23.98-.63 1.38-.4.4-.86.61-1.38.63-.83.02-1.48.16-2 .45V4.72a1.993 1.993 0 0 0-1-3.72C.88 1 0 1.89 0 3a2 2 0 0 0 1 1.72v6.56c-.59.35-1 .99-1 1.72 0 1.11.89 2 2 2 1.11 0 2-.89 2-2 0-.53-.2-1-.53-1.36.09-.06.48-.41.59-.47.25-.11.56-.17.94-.17 1.05-.05 1.95-.45 2.75-1.25S8.95 7.77 9 6.73h-.02C9.59 6.37 10 5.73 10 5zM2 1.8c.66 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2C1.35 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2zm0 12.41c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm6-8c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg> Network'; | |
butt.className = "js-selected-navigation-item reponav-item nwk-butt"; | |
rn.appendChild(butt); | |
} | |
} | |
addNetworkButton(); | |
document.querySelector('head').addEventListener('DOMNodeRemoved', function() { | |
addNetworkButton(); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment