GitHub Make Tooltips

A userscript converts title tooltips into Github Tooltips

目前為 2019-07-08 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name GitHub Make Tooltips
  3. // @version 1.0.5
  4. // @description A userscript converts title tooltips into Github Tooltips
  5. // @license MIT
  6. // @author StylishThemes
  7. // @namespace https://github.com/StylishThemes
  8. // @include https://github.com/*
  9. // @run-at document-idle
  10. // @grant GM_addStyle
  11. // @icon https://avatars3.githubusercontent.com/u/6145677?v=3&s=200
  12. // ==/UserScript==
  13. (() => {
  14. "use strict";
  15.  
  16. GM_addStyle(".news .alert, .news .alert .body { overflow: visible !important; }");
  17.  
  18. function init() {
  19. let indx = 0;
  20. const els = document.querySelector("body").querySelectorAll("[title]");
  21. const regex = /(link|time-ago|relative-time)/gi;
  22. const len = els.length;
  23.  
  24. // loop with delay to allow user interaction
  25. function loop() {
  26. let el, txt, direction,
  27. // max number of DOM modifications per loop
  28. max = 0;
  29. while (max < 20 && indx < len) {
  30. if (indx >= len) {
  31. return;
  32. }
  33. el = els[indx];
  34. if (!regex.test(el.nodeName) && !el.classList.contains("tooltipped")) {
  35. txt = el.title || "";
  36. // Change direction of star & fork tooltips - fixes #30
  37. direction = el.classList.contains("btn-with-count") ?
  38. "tooltipped-s" :
  39. "tooltipped-n";
  40. el.classList.add(...["tooltipped", direction]);
  41. if (txt.length > 45) {
  42. el.classList.add("tooltipped-multiline");
  43. }
  44. el.setAttribute("aria-label", txt);
  45. el.removeAttribute("title");
  46. max++;
  47. }
  48. indx++;
  49. }
  50. if (indx < len) {
  51. setTimeout(() => {
  52. loop();
  53. }, 200);
  54. }
  55. }
  56. loop();
  57. }
  58.  
  59. init();
  60. document.addEventListener("pjax:end", init);
  61. })();

QingJ © 2025

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