[Github] User-mention to profile page

Changes the user-mention URL to the user's profile page

  1. // ==UserScript==
  2. // @name [Github] User-mention to profile page
  3. // @namespace HKR
  4. // @match https://github.com/*
  5. // @grant none
  6. // @version 1.0
  7. // @author HKR
  8. // @description Changes the user-mention URL to the user's profile page
  9. // @supportURL https://github.com/Hakorr/Userscripts/issues
  10. // ==/UserScript==
  11.  
  12. document.addEventListener('readystatechange', event => {
  13. if (event.target.readyState === "complete") {
  14. var mentions = document.getElementsByClassName("commit-author user-mention");
  15.  
  16. for (var i = 0; i < mentions.length; i++) {
  17. var username = mentions[i].getAttribute("href");
  18. username = username.substring(username.indexOf('='));
  19. username = username.substring(1);
  20.  
  21. if(!username.includes('/') && !username.includes('.'))
  22. var user_url = "https://github.com/" + username;
  23. else
  24. var user_url = "none";
  25.  
  26. if(user_url != "none") {
  27. mentions[i].setAttribute("href", user_url);
  28. }
  29. }
  30. }
  31. });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址