GitHub Boldless Title

GitHub 仓库名取消加粗

  1. // ==UserScript==
  2. // @name GitHub Boldless Title
  3. // @namespace https://github.com/Vinfall/UserScripts
  4. // @version 1.2.0
  5. // @author Vinfall
  6. // @match https://github.com/*
  7. // @match https://gist.github.com/*
  8. // @exclude-match https://github.com/login
  9. // @exclude-match https://github.com/sessions/*
  10. // @exclude-match https://github.com/signin
  11. // @exclude-match https://gist.github.com/auth/*
  12. // @exclude-match https://gist.github.com/join*
  13. // @exclude-match https://gist.github.com/login
  14. // @grant none
  15. // @run-at document-end
  16. // @license CC0 1.0 Universal (Public Domain)
  17. // @description Remove strong style in GitHub repo/gist title
  18. // @description:zh-cn GitHub 仓库名取消加粗
  19. // ==/UserScript==
  20.  
  21. (() => {
  22. function replaceStrongWithAnchor(selector) {
  23. const strongElements = document.querySelectorAll(selector);
  24. for (const strong of strongElements) {
  25. const anchor = strong.querySelector('a'); // Select the <a> tag inside <strong>
  26. if (anchor) {
  27. // Create a new <a> element
  28. const newAnchor = document.createElement('a');
  29. newAnchor.href = anchor.href; // Preserve the href
  30. newAnchor.textContent = anchor.textContent; // Preserve the text content
  31.  
  32. // Replace the <strong> element with the new <a> element in the DOM
  33. strong.parentNode.replaceChild(newAnchor, strong);
  34. }
  35. }
  36. }
  37.  
  38. // Run after the window has fully loaded
  39. window.onload = () => {
  40. const isGist = window.location.href.includes('gist');
  41. const selector = isGist ? 'strong[itemprop="name"].css-truncate-target.mr-1' : 'strong.mr-2.flex-self-stretch';
  42. replaceStrongWithAnchor(selector);
  43.  
  44. // Observe changes in the page (e.g., for dynamic content)
  45. const observer = new MutationObserver(replaceStrongWithAnchor);
  46. observer.observe(document.body, { childList: true, subtree: true });
  47. };
  48. })();