Github.com - Extra header links

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

  1. // ==UserScript==
  2. // @name Github.com - Extra header links
  3. // @namespace r-a-y/github/watching/homepage
  4. // @description Adds "Stars" and "Watching" links, as well as your user profile link, to the header alongside the existing "Pull Requests", "Issues" and "Gist" links.
  5. // @match https://github.com/*
  6. // @version 1.2.3
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. var nav, watchingLink, starLink, user, userLink;
  11.  
  12. nav = document.querySelector('header nav');
  13.  
  14. watchingLink = document.createElement('a');
  15. watchingLink.href = '/watching';
  16. watchingLink.setAttribute( 'class', 'mr-lg-3' );
  17. watchingLink.innerHTML = 'Watching';
  18.  
  19. starLink = document.createElement('a');
  20. starLink.href = '/stars';
  21. starLink.setAttribute( 'class', 'mr-lg-3' );
  22. starLink.innerHTML = 'Stars';
  23.  
  24. user = document.querySelector('.header-nav-current-user .css-truncate-target').textContent;
  25.  
  26. userLink = document.createElement('a');
  27. userLink.href = '/' + user;
  28. userLink.setAttribute( 'class', 'mr-lg-3' );
  29. userLink.innerHTML = user;
  30.  
  31. nav.appendChild( starLink );
  32. nav.appendChild( watchingLink );
  33. nav.appendChild( userLink );