GitHub Link Dashboard Avatar

A userscript that links the avatar on the GitHub dashboard to its profile or organization.

  1. // ==UserScript==
  2. // @name GitHub Link Dashboard Avatar
  3. // @namespace https://github.com/ikelax/userscripts
  4. // @match https://github.com/
  5. // @match https://github.com/orgs/*/dashboard
  6. // @grant none
  7. // @version 0.1.0
  8. // @author Alexander Ikonomou
  9. // @description A userscript that links the avatar on the GitHub dashboard to its profile or organization.
  10. // @license MIT
  11. // @supportURL https://github.com/ikelax/userscripts/issues
  12. // @copyright 2025, Alexander Ikonomou (https://github.com/ikelax)
  13. // @homepageURL https://github.com/ikelax/userscripts
  14. // @homepage https://github.com/ikelax/userscripts
  15. // @contributionURL https://github.com/ikelax/userscripts
  16. // @collaborator ikelax
  17. // @icon https://github.githubassets.com/pinned-octocat.svg
  18. // ==/UserScript==
  19.  
  20. (() => {
  21. "use strict";
  22.  
  23. const avatar = document.querySelector(
  24. "div.dashboard-sidebar img.avatar-small",
  25. );
  26.  
  27. if (avatar == null) {
  28. return;
  29. }
  30.  
  31. const link = document.createElement("a");
  32. link.setAttribute("href", getLink(avatar.getAttribute("alt")));
  33.  
  34. wrap(avatar, link);
  35.  
  36. /**
  37. * Wraps `elementToWrap` with `outerElement`.
  38. *
  39. * @example `elementToWrap` is an image `<img />`.
  40. * `outerElement` is a link `<a href="https://"><a>
  41. *
  42. * @param {*} elementToWrap The inner element
  43. * @param {*} outerElement The outer element
  44. */
  45. function wrap(elementToWrap, outerElement) {
  46. outerElement.innerHTML = elementToWrap.outerHTML;
  47. elementToWrap.parentNode.insertBefore(outerElement, elementToWrap);
  48. elementToWrap.remove();
  49. }
  50.  
  51. /**
  52. * @param {*} atName The reference to a user or an organization
  53. * @returns The link to the profile of the user or the organization
  54. */
  55. function getLink(atName) {
  56. const name = atName.replace("@", "");
  57. return `https://github.com/${name}`;
  58. }
  59. })();