Hide StackOverflow Sidebars

The minimum viable StackOverflow UI while removing all distractions

  1. // ==UserScript==
  2. // @name Hide StackOverflow Sidebars
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-01-21b
  5. // @description The minimum viable StackOverflow UI while removing all distractions
  6. // @author Kristian Rados
  7. // @license MIT
  8.  
  9. // @match *://superuser.com/questions/*
  10. // @match *://stackoverflow.com/questions/*
  11. // @match *://askubuntu.com/questions/*
  12. // @match *://serverfault.com/questions/*
  13. // @match *://*.stackexchange.com/questions/*
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. 'use strict';
  18.  
  19. // Remove left sidebar (I have not used it a single time in my life)
  20. var removables = ['left-sidebar']; // Can add more IDs here
  21. for (var i = 0; i < removables.length; i++) {
  22. var element = document.getElementById(removables[i]);
  23. if (element) {
  24. element.parentNode.removeChild(element);
  25. }
  26. }
  27. document.getElementById("content").style.border="none";
  28.  
  29. // Make question and answers take up whole width of page
  30. document.getElementById("content").style.margin="0";
  31. document.getElementById("content").style.width="100%";
  32. document.getElementById("content").style.maxWidth="none";
  33.  
  34. // Moves Linked and Related questions to bottom of page
  35. // COMMENT OUT this line if you prefer them next to the question
  36. document.getElementById("mainbar").style.width="auto";
  37.  
  38. // Clean up right sidebar
  39. // Adapted from https://github.com/ShivanKaul/SidebarOverflow/blob/master/extension/src/remove.js
  40. var hiring = document.getElementById("hireme");
  41. var meta = document.getElementById("sidebar").children[0];
  42. var hot_network_qs = document.getElementById("hot-network-questions");
  43. var chat = document.getElementById("chat-feature");
  44. if (hiring) {
  45. hiring.parentNode.removeChild(hiring);
  46. }
  47. if (meta) {
  48. meta.parentNode.removeChild(meta);
  49. }
  50. if (hot_network_qs) {
  51. hot_network_qs.parentNode.removeChild(hot_network_qs);
  52. }
  53. if (chat) {
  54. chat.parentNode.removeChild(chat);
  55. }
  56. })();