StackExchange Tweaks

Minor visual tweaks to StackExchange (remove the new sidebar from Q/A pages, for classic look)

As of 2019-08-26. See the latest version.

  1. // ==UserScript==
  2. // @name StackExchange Tweaks
  3. // @namespace SET
  4. // @description Minor visual tweaks to StackExchange (remove the new sidebar from Q/A pages, for classic look)
  5. // @version 1.0.14
  6. // @license MIT
  7. // @include https://stackoverflow.com/*
  8. // @include https://*.stackoverflow.com/*
  9. // @include https://superuser.com/*
  10. // @include https://serverfault.com/*
  11. // @include https://*.stackexchange.com/*
  12. // @include https://askubuntu.com/*
  13. // @include https://mathoverflow.net/*
  14. // @include https://stackapps.com/*
  15. // @grant GM_addStyle
  16. // ==/UserScript==
  17.  
  18. // ==Options==
  19.  
  20. // Swap the positions of the notifications block and the username/stats block
  21. // in the header
  22. //
  23. // This pushes the user profile off towards the corner, and brings the action
  24. // buttons closer to the center
  25. //
  26. var swapProfileAndButtons = true;
  27.  
  28. // Hide the 2018 sidebar when we are on question pages (reduces visual noise)
  29. //
  30. var hideSidebarOnQuestionPages = true;
  31.  
  32. // If you don't like things to be 3D when they don't need to be
  33. //
  34. var noShadows = true;
  35.  
  36. // Lighten the new stats above the question, if you find them distracting
  37. //
  38. var deemphasiseStats = true;
  39.  
  40. // ==/Options==
  41.  
  42. if (swapProfileAndButtons) {
  43. //var secondaryNav = document.querySelector('.secondary-nav')
  44. //secondaryNav.parentNode.insertBefore(secondaryNav, secondaryNav.parentNode.firstChild)
  45. var profileElementInner = document.querySelector('.my-profile');
  46. if (profileElementInner) {
  47. var profileElementContainer = profileElementInner.parentNode;
  48. profileElementContainer.parentNode.appendChild(profileElementContainer);
  49. } else {
  50. console.warn("Could not find .my-profile element");
  51. }
  52. }
  53.  
  54. if (hideSidebarOnQuestionPages) {
  55. if (document.location.pathname.match(/^\/(q|questions)\//)) {
  56. GM_addStyle('#left-sidebar { display: none; }');
  57. // On some sites this leaves an unnecessary line down the left of the content, which we can remove.
  58. // But on some sites, the lines is an all sides, so we don't want to remove it!
  59. /*
  60. if (document.location.hostname.match(/^(stackoverflow.com|(politics|physics|earthscience).stackexchange.com)$/)) {
  61. GM_addStyle('#content { border-left: none; }');
  62. }
  63. */
  64. // General purpose solution: do on the left whatever the right is doing.
  65. const contentElem = document.querySelector('#content');
  66. if (contentElem) {
  67. contentElem.style.borderLeft = getComputedStyle(contentElem)['border-right'];
  68. }
  69. }
  70. }
  71.  
  72. if (noShadows) {
  73. // The "Featured on Meta" box on the right, above "Related" and "Hot Network Questions"
  74. GM_addStyle('.s-sidebarwidget { box-shadow: none; }');
  75. }
  76.  
  77. if (deemphasiseStats) {
  78. // There isn't a clear ID or class for the stats, so I used this monstrosity
  79. GM_addStyle('#question-header + .grid.fw-wrap.bb { opacity: 0.7; font-size: 0.9em; }');
  80. }