fandom.com - Remove bloatware

Removes unnecessary elements from fandom website, leaving only what's important.

Verze ze dne 08. 10. 2024. Zobrazit nejnovější verzi.

  1. // ==UserScript==
  2. // @grant none
  3. // @version 1.1.1
  4. // @author eye-wave
  5. // @icon https://raw.githubusercontent.com/eye-wave/greasy-fork/main/packages/fandom-debloat/assets/icon.svg
  6. // @license GPL-3.0+
  7. // @description:de Entfernt unnötige Elemente von der Fandom-Website und lässt nur das Wichtige übrig.
  8. // @description:es Elimina elementos innecesarios del sitio web de fandom, dejando solo lo importante.
  9. // @description:fr Supprime les éléments inutiles du site web de fandom, ne laissant que l'essentiel.
  10. // @description:jp ファンダムのウェブサイトから不必要な要素を削除し、重要なもののみを残します。
  11. // @description:pl Usuwa zbędne elementy ze strony fandomu, pozostawiając tylko to, co ważne.
  12. // @description:ru Удаляет ненужные элементы с веб-сайта фандома, оставляя только то, что важно.
  13. // @name:de fandom.com - Bloatware entfernen
  14. // @name:es fandom.com - Eliminar el software basura
  15. // @name:fr fandom.com - Supprimer les logiciels superflus
  16. // @name:jp fandom.com - お膨らみを取り除く
  17. // @name:pl fandom.com - Uprość UI
  18. // @name:ru fandom.com - Удаление ненужного программного обеспечения
  19. // @name fandom.com - Remove bloatware
  20. // @namespace fandom.com utils
  21. // @match https://*.fandom.com/*
  22. // @description Removes unnecessary elements from fandom website, leaving only what's important.
  23. // ==/UserScript==
  24. // src/window.js
  25. window.ads = void 0;
  26.  
  27. // ../../utils/src/index.ts
  28. function $(query) {
  29. return document.querySelectorAll(query);
  30. }
  31. function $s(query) {
  32. return document.querySelector(query);
  33. }
  34.  
  35. // src/search.ts
  36. function fixSearch() {
  37. const search = $s("a[title='Search']");
  38. if (search) {
  39. search.removeAttribute("data-tracking");
  40. search.onclick = function() {
  41. window.location.pathname = "/wiki/Special:Search";
  42. };
  43. }
  44. }
  45.  
  46. // src/index.ts
  47. var toResize = [".fandom-community-header__background", ".main-container"];
  48. var massRemove = ["iframe", "link[as='script']", "meta", "script", "style:not([type='text/css'])"];
  49. var removeListSingle = [
  50. ".bottom-ads-container",
  51. ".fandom-sticky-header",
  52. ".global-navigation",
  53. ".global-registration-buttons",
  54. ".notifications-placeholder",
  55. ".page__right-rail",
  56. ".page-side-tools",
  57. ".right-rail-wrapper",
  58. ".top-ads-container",
  59. ".unified-search__layout__right-rail",
  60. "#age-gate",
  61. "#featured-video__player-container",
  62. "#global-explore-navigation",
  63. "#p-views",
  64. "#WikiaBar",
  65. "#mixed-content-footer",
  66. "div>div[data-tracking-opt-in-overlay]",
  67. "footer"
  68. ];
  69. removeBloatware();
  70. function removeBloatware() {
  71. removeListSingle.forEach((q) => $s(q)?.remove());
  72. massRemove.forEach((q) => $(q).forEach((e) => e?.remove()));
  73. toResize.forEach((q) => $s(q)?.setAttribute("style", "width:100%;margin:0"));
  74. }
  75. removeExcessiveBodyClassNames();
  76. function removeExcessiveBodyClassNames() {
  77. for (const c of document.body.classList) {
  78. if (c.includes("skin-fandom"))
  79. continue;
  80. document.body.classList.remove(c);
  81. }
  82. }
  83. function removeExcessiveHtmlAttrs() {
  84. document.documentElement.removeAttribute("class");
  85. document.documentElement.removeAttribute("dir");
  86. document.documentElement.removeAttribute("style");
  87. }
  88. new MutationObserver((mutationsList) => {
  89. for (const mutation of mutationsList) {
  90. if (mutation.type === "childList") {
  91. removeBloatware();
  92. fixSearch();
  93. }
  94. if (mutation.type === "attributes") {
  95. removeExcessiveBodyClassNames();
  96. removeExcessiveHtmlAttrs();
  97. }
  98. }
  99. }).observe(document.documentElement, {
  100. childList: true,
  101. subtree: true,
  102. attributes: true,
  103. attributeOldValue: true
  104. });