liteoverflow

remove all unrelated elements of stackoverflow

  1. // ==UserScript==
  2. // @description remove all unrelated elements of stackoverflow
  3. // @name liteoverflow
  4. // @namespace https://github.com/kevin335200/liteoverflow
  5. // @version 1.01
  6. // @grant none
  7. // @include http*://stackoverflow.com/*
  8. // @author kevin335200
  9. // @run-at document-end
  10. // ==/UserScript==
  11.  
  12. // CSS Wide Screen
  13. function addGlobalStyle(css) {
  14. var head, style;
  15. head = document.getElementsByTagName("head")[0];
  16. if (!head) {
  17. return;
  18. }
  19. style = document.createElement("style");
  20. style.type = "text/css";
  21. style.innerHTML = css;
  22. head.appendChild(style);
  23. }
  24.  
  25. addGlobalStyle("#mainbar, .mainbar{width: calc(100%) ! important;}");
  26. addGlobalStyle(
  27. "#content{max-width: 2000px ! important; width: calc(100%) ! important;}"
  28. );
  29.  
  30. function turnoff_class(className) {
  31. let ele = document.getElementsByClassName(className);
  32.  
  33. while (ele[0]) {
  34. ele[0].parentNode.removeChild(ele[0]);
  35. }
  36. }
  37.  
  38. function turnoff_id(id) {
  39. let ele = document.getElementById(id);
  40. ele.parentNode.removeChild(ele);
  41. }
  42.  
  43. async function hide_query(query) {
  44. let ele = document.querySelector(query);
  45. while (ele[0]) {
  46. ele[0].parentNode.removeChild(ele[0]);
  47. }
  48. }
  49.  
  50. function hide_class(className) {
  51. let ele = document.getElementsByClassName(className);
  52. let n = ele.length;
  53.  
  54. for (var i = 0; i < n; i++) {
  55. ele[i].style.display = "none";
  56. }
  57. }
  58.  
  59. // "Products" Button
  60. turnoff_class("list-reset grid gs4");
  61. turnoff_class("-marketing-link js-gps-track js-products-menu");
  62.  
  63. // Left Sidebar
  64. turnoff_class("left-sidebar");
  65.  
  66. turnoff_class("module sidebar-related");
  67.  
  68. // Feed
  69. turnoff_class("js-feed-link");
  70.  
  71. // User Infos (edited time, gravatar, etc)
  72. // turnoff_class("user-action-time");
  73. // turnoff_class("user-gravatar32");
  74.  
  75. // Edit Button
  76. turnoff_class("s-btn s-btn__link js-error-click js-gps-track");
  77. turnoff_class("js-suggest-edit-post js-gps-track");
  78.  
  79. // Follow Button
  80. turnoff_class(
  81. "s-btn s-btn__link js-follow-post js-follow-question js-gps-track"
  82. );
  83. turnoff_class("s-btn s-btn__link js-follow-post js-follow-answer js-gps-track");
  84.  
  85. // Comment Button
  86. turnoff_class("js-add-link comments-link disabled-link");
  87.  
  88. // Vote Button
  89. turnoff_class("js-vote-up-btn grid--cell s-btn s-btn__unset c-pointer");
  90. turnoff_class("js-vote-down-btn grid--cell s-btn s-btn__unset c-pointer");
  91.  
  92. // Ask Button
  93. turnoff_class("ws-nowrap s-btn s-btn__primary");
  94.  
  95. // The Overflow Blog
  96. turnoff_class("s-sidebarwidget__yellow");
  97.  
  98. // Linked Questions
  99. turnoff_class("sidebar-linked");
  100.  
  101. // Bottom Notice
  102. turnoff_class("bottom-notice");
  103.  
  104. // Footer
  105. turnoff_class("site-footer js-footer");
  106.  
  107. // Hot Questions
  108. turnoff_id("hot-network-questions");
  109.  
  110. // Love This Site
  111. turnoff_class("s-sidebarwidget--header");
  112.  
  113. // Newspaper
  114. turnoff_class("s-sidebarwidget--content d-block");
  115.  
  116. // Chat Room
  117. turnoff_class(
  118. "s-sidebarwidget--content s-sidebarwidget__items js-chat-ad-rooms"
  119. );
  120.  
  121. // Markdown Editor
  122. hide_class("post-form");
  123. hide_class("no-answers");
  124.  
  125. // Survey Banner
  126. turnoff_class("grid jc-space-between wmx12 mx-auto px16 py8");
  127. turnoff_class("js-announcement-banner bg-black-700 fc-white ff-sans fs-body2 py2");
  128.  
  129. // Sign Up Bottom Bar
  130. turnoff_class("grid wmx12 mx-auto px8 py12 jc-space-between ai-center lg:pl24 lg:pr24 md:fd-column sm:fd-row sm:ai-center")