Remove Social Media for github.com

This userscript removes the "x followers", "y following" and "Set Status" fields on your own github.com profile page. This is just visual.

安裝腳本?
作者推薦腳本

您可能也會喜歡 Remove Social Media for gist.github.com

安裝腳本
  1. // ==UserScript==
  2. // @name Remove Social Media for github.com
  3. // @description This userscript removes the "x followers", "y following" and "Set Status" fields on your own github.com profile page. This is just visual.
  4. // @author ths197
  5. // @license BSD-3-Clause
  6. // @namespace https://gist.github.com/ths197
  7. // @include https://github.com
  8. // @include https://github.com/*
  9. // @noframes
  10. // @run-at document-start
  11. // @version 0.0.1.20250509081637
  12. // ==/UserScript==
  13.  
  14. "use strict";
  15.  
  16. // conditions
  17.  
  18. const isOnLoginUsersHomePage = () => document.body.classList.contains("mine");
  19.  
  20. var state = undefined;
  21.  
  22. const isChanged = () => !state?.isConnected;
  23.  
  24. // getting and removing
  25.  
  26. const getProfile = () =>
  27. document.body.getElementsByClassName("js-profile-editable-replace")[0];
  28.  
  29. const socialMediaUrlOptions = ["followers", "following"];
  30.  
  31. const removeSocialMediaButtons = function (node) {
  32. const links = Array.from(node.getElementsByTagName("a"));
  33. const anySocialMediaLink = links.find((node) =>
  34. socialMediaUrlOptions.some((option) =>
  35. new URLSearchParams(new URL(node.href).search).has("tab", option)
  36. )
  37. );
  38. anySocialMediaLink?.parentElement.remove();
  39. Array.from(node.getElementsByClassName("user-status-container")).forEach(
  40. (statusContainer) => statusContainer.remove()
  41. );
  42. };
  43.  
  44. // applying
  45.  
  46. const applyChanges = function () {
  47. if (isOnLoginUsersHomePage()) {
  48. state = getProfile();
  49. if (state != null) {
  50. removeSocialMediaButtons(state);
  51. }
  52. }
  53. };
  54.  
  55. // setting stuff up (boring)
  56.  
  57. const innerObserver = new MutationObserver(function () {
  58. if (isChanged()) {
  59. applyChanges();
  60. }
  61. });
  62.  
  63. const outerObserver = new MutationObserver(function () {
  64. if (isChanged()) {
  65. applyChanges();
  66. attachInnerObserver();
  67. }
  68. });
  69.  
  70. const attachInnerObserver = function () {
  71. const profile = getProfile();
  72. if (profile != null) {
  73. innerObserver.observe(profile.parentElement, {
  74. subtree: false,
  75. childList: true,
  76. });
  77. }
  78. };
  79.  
  80. const attachOuterObserver = () =>
  81. outerObserver.observe(document.body, { subtree: false, childList: true });
  82.  
  83. const init = function () {
  84. applyChanges();
  85. attachOuterObserver();
  86. attachInnerObserver();
  87. };
  88.  
  89. if (document.readyState === "loading") {
  90. document.addEventListener("DOMContentLoaded", init);
  91. } else {
  92. init();
  93. }