Github: Add more links to nav.

Add profile link to nav bar.

  1. // ==UserScript==
  2. // @name Github: Add more links to nav.
  3. // @namespace https://greasyfork.org/zh-CN/scripts/397263
  4. // @version 0.5.0
  5. // @description Add profile link to nav bar.
  6. // @author Al Cheung
  7. // @match *://github.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13. var $ = document.querySelector.bind(document);
  14.  
  15. function appendLink(url, text) {
  16. const a = document.createElement(`a`);
  17. a.className = `js-selected-navigation-item Header-link mt-md-n3 mb-md-n3 py-2 py-md-3 mr-0 mr-md-3 border-top border-md-top-0 border-white-fade-15`;
  18. a.innerText = text;
  19. a.href = url;
  20. const headerList = $(`nav.d-flex`);
  21. headerList.appendChild(a);
  22. }
  23.  
  24. const userName = $(`details > summary > img`).alt.replace(`@`, '');
  25.  
  26. appendLink(`//github.com/${userName}?tab=stars`, `My Stars`);
  27. appendLink(`//github.com/${userName}`, `My Profile`);
  28. })();