Github.com - Extra header links - modified

Adds "Stars" link, as well as your user profile link, to the header alongside the existing "Pull Requests", "Issues" and "Gist" links.

Verze ze dne 23. 04. 2020. Zobrazit nejnovější verzi.

// ==UserScript==
// @name        Github.com - Extra header links - modified
// @namespace   
// @description Adds "Stars" link, as well as your user profile link, to the header alongside the existing "Pull Requests", "Issues" and "Gist" links.
// @include     https://github.com/*
// @version     2.1.0
// @grant       none
// ==/UserScript==

var nav = document.querySelectorAll('nav.d-flex')[0];
var className = 'js-selected-navigation-item Header-link py-lg-3  mr-0 mr-lg-3 py-2 border-top border-lg-top-0 border-white-fade-15';
var starLink = document.createElement('a');
starLink.href = '/stars';
starLink.setAttribute( 'class', className );
starLink.innerHTML = 'Stars';

var topicLink = document.createElement('a');
topicLink.href = '/topics';
topicLink.setAttribute( 'class', className );
topicLink.innerHTML = 'Topics';


var user = document.getElementsByClassName('user-profile-link');
if(user && user.length > 0) {
    user = user[0].childNodes[1].textContent;
} else {
    user = document.getElementsByClassName('css-truncate-target')[0].textContent;
}

var userLink = document.createElement('a');
userLink.href = '/' + user;
userLink.setAttribute( 'class', className );
userLink.innerHTML = user;

nav.appendChild( starLink );
nav.appendChild( topicLink );
nav.appendChild( userLink );