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.

目前为 2017-10-24 提交的版本。查看 最新版本

  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. // @include https://github.com/*
  6. // @version 1.2.2
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. var nav = document.querySelector('header.Header ul');
  11.  
  12. var watchingLink = document.createElement('a');
  13. watchingLink.href = '/watching';
  14. watchingLink.setAttribute( 'class', 'HeaderNavlink px-2' );
  15. //watchingLink.innerHTML = '<span class="octicon octicon-eye"> </span> Watching';
  16. watchingLink.innerHTML = 'Watching';
  17.  
  18. var watchingLi = document.createElement("li");
  19. watchingLi.setAttribute( 'class', 'header-nav-item' );
  20. watchingLi.appendChild(watchingLink);
  21.  
  22. var starLink = document.createElement('a');
  23. starLink.href = '/stars';
  24. starLink.setAttribute( 'class', 'HeaderNavlink px-2' );
  25. starLink.innerHTML = 'Stars';
  26.  
  27. var starLi = document.createElement("li");
  28. starLi.setAttribute( 'class', 'header-nav-item' );
  29. starLi.appendChild(starLink);
  30.  
  31. var user = document.getElementsByClassName('header-nav-current-user');
  32. user = user[0].childNodes[1].textContent;
  33.  
  34. var userLink = document.createElement('a');
  35. userLink.href = '/' + user;
  36. userLink.setAttribute( 'class', 'HeaderNavlink px-2' );
  37. userLink.innerHTML = user;
  38.  
  39. var userLi = document.createElement("li");
  40. userLi.setAttribute( 'class', 'header-nav-item' );
  41. userLi.appendChild(userLink);
  42.  
  43. nav.appendChild( starLi );
  44. nav.appendChild( watchingLi );
  45. nav.appendChild( userLi );