Unxitter – Twitter X Logo Remover

Userscript that Unxittifies Twitter

  1. // ==UserScript==
  2. // @name Unxitter – Twitter X Logo Remover
  3. // @description Userscript that Unxittifies Twitter
  4. // @icon https://abs.twimg.com/favicons/twitter.2.ico
  5. // @namespace Violentmonkey Scripts
  6. // @match https://twitter.com/*
  7. // @match https://mobile.twitter.com/*
  8. // @grant GM_addStyle
  9. // @run-at document-start
  10. // @version 0.9
  11. // @author Mozzie
  12. // @license MIT
  13. // ==/UserScript==
  14.  
  15. // REPLACE LOGO
  16. // ==============================
  17.  
  18. // Find the elements to modify...
  19. const svgSelector = `svg:is(.r-13v1u17, .r-1p0dtai, .r-16y2uox) > g > path`;
  20. const faviconSelector = `link[rel="shortcut icon"]`;
  21.  
  22. // Replace the icon's SVG using CSS
  23. const twitterLogoPath = `M23.643 4.937c-.835.37-1.732.62-2.675.733.962-.576 1.7-1.49 2.048-2.578-.9.534-1.897.922-2.958
  24. 1.13-.85-.904-2.06-1.47-3.4-1.47-2.572 0-4.658 2.086-4.658 4.66 0 .364.042.718.12
  25. 1.06-3.873-.195-7.304-2.05-9.602-4.868-.4.69-.63 1.49-.63 2.342 0 1.616.823 3.043 2.072
  26. 3.878-.764-.025-1.482-.234-2.11-.583v.06c0 2.257 1.605 4.14 3.737 4.568-.392.106-.803.162-1.227.162-.3
  27. 0-.593-.028-.877-.082.593 1.85 2.313 3.198 4.352 3.234-1.595 1.25-3.604 1.995-5.786 1.995-.376
  28. 0-.747-.022-1.112-.065 2.062 1.323 4.51 2.093 7.14 2.093 8.57 0 13.255-7.098 13.255-13.254
  29. 0-.2-.005-.402-.014-.602.91-.658 1.7-1.477 2.323-2.41z`.replace(/\n/g, "");
  30. const logoStyleRule = `
  31. :is(${svgSelector}) {
  32. fill: inherit;
  33. d: path("${twitterLogoPath}");
  34. }
  35. `;
  36. GM_addStyle(logoStyleRule);
  37.  
  38. // REPLACE FAVICON
  39. // =================================
  40. {
  41. const twitterFaviconURL = "https://abs.twimg.com/favicons/twitter.2.ico";
  42. const twitterFaviconPipURL = 'https://abs.twimg.com/favicons/twitter-pip.2.ico';
  43.  
  44. // create a new <link>. the browser should show this one until the old one changes.
  45. const newLink = document.createElement("link");
  46. newLink.setAttribute("rel", "icon");
  47. newLink.setAttribute("href", twitterFaviconURL);
  48. document.head?.appendChild(newLink);
  49.  
  50. // Replace the Favicon
  51. document.addEventListener("DOMContentLoaded", () => {
  52. // move new favicon to the end of the head in case the head wasn't done loading.
  53. document.head.appendChild(newLink);
  54.  
  55. // the old <link rel="icon">
  56. const oldLink = document.querySelector(faviconSelector);
  57. oldLink.setAttribute("media", "print"); // <- try to stop it from loading
  58.  
  59. // callback to update our URL
  60. const updateFavicon = () => {
  61. // check if the "real" link has the notification pip.
  62. const hasPip = oldLink.getAttribute("href").includes("pip");
  63. newLink.setAttribute("href", hasPip ? twitterFaviconPipURL : twitterFaviconURL);
  64. }
  65.  
  66. const config = { attributes: true, attributeFilter: ["href"], attributeOldValue: true };
  67.  
  68. // Watch the old link for changes.
  69. const observer = new MutationObserver(updateFavicon);
  70. observer.observe(oldLink, config);
  71. });
  72. }
  73. // RENAME TAB TITLE
  74. // ================================
  75. window.addEventListener("load", () => {
  76. // <title>Home / X</title>
  77. const title = document.querySelector("title");
  78. // get the X
  79. const regexp = /(\bX$|(?<=on )X(?=:))/g;
  80. // callback to replace it
  81. const updateTitle = () => {
  82. if (regexp.test(title.innerHTML)) {
  83. title.innerHTML = title.innerHTML
  84. .replace(regexp, "Twitter");
  85. }
  86. }
  87. // call once on load
  88. updateTitle();
  89. // watch the title element for changes.
  90. const observer = new MutationObserver(updateTitle);
  91. observer.observe(title, {
  92. childList: true
  93. });
  94. });
  95.  
  96. // Done. Good puppy!

QingJ © 2025

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