StackExchange Tweaks

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

目前为 2018-10-21 提交的版本。查看 最新版本

  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.9
  6. // @license MIT
  7. // @include https://stackoverflow.com/*
  8. // @include https://superuser.com/*
  9. // @include https://serverfault.com/*
  10. // @include https://*.stackexchange.com/*
  11. // @include https://askubuntu.com/*
  12. // @grant GM_addStyle
  13. // ==/UserScript==
  14.  
  15. // ==Options==
  16.  
  17. // Swap the positions of the notifications block and the username/stats block
  18. // in the header
  19. //
  20. // This pushes the user profile off towards the corner, and brings the action
  21. // buttons closer to the center
  22. //
  23. var swapProfileAndButtons = true;
  24.  
  25. // Hide the 2018 sidebar when we are on question pages (reduces visual noise)
  26. //
  27. var hideSidebarOnQuestionPages = true;
  28.  
  29. // ==/Options==
  30.  
  31. if (swapProfileAndButtons) {
  32. //var secondaryNav = document.querySelector('.secondary-nav')
  33. //secondaryNav.parentNode.insertBefore(secondaryNav, secondaryNav.parentNode.firstChild)
  34. var profileElementInner = document.querySelector('.my-profile');
  35. if (profileElementInner) {
  36. var profileElementContainer = profileElementInner.parentNode;
  37. profileElementContainer.parentNode.appendChild(profileElementContainer);
  38. } else {
  39. console.warn("Could not find .my-profile element");
  40. }
  41. }
  42.  
  43. if (hideSidebarOnQuestionPages) {
  44. if (document.location.pathname.match(/^\/(q|questions)\//)) {
  45. GM_addStyle('#left-sidebar { display: none; }');
  46. if (document.location.hostname.match(/^(stackoverflow.com|(politics|physics).stackexchange.com)$/)) {
  47. GM_addStyle('#content { border-left: none; }');
  48. }
  49. }
  50. }