Revert StackExchange Formatting

Brings back the old line-height, colors, padding, borders, etc. of StackExchange websites like StackOverflow, SuperUser, ServerFault, etc.

Fra 28.08.2020. Se den seneste versjonen.

  1. // ==UserScript==
  2. // @name Revert StackExchange Formatting
  3. // @namespace https://github.com/Prid13/Revert-StackExchange-Formatting
  4. // @version 1.0
  5. // @description Brings back the old line-height, colors, padding, borders, etc. of StackExchange websites like StackOverflow, SuperUser, ServerFault, etc.
  6. // @author Prid
  7. // @include /^https://(?:[^/]+\.)?(?:(?:stackoverflow|serverfault|superuser|stackexchange|askubuntu|stackapps)\.com|mathoverflow\.net)//
  8. // @run-at document-start
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. var style = "";
  16.  
  17. var values = {
  18. line_height: 1.3,
  19.  
  20. code_block_bgcol: "#eff0f1",
  21. code_block_padding: "12px 8px",
  22. code_block_radius: "3px",
  23.  
  24. inline_code_bgcol: "#e4e6e8",
  25. inline_code_padding: "1px 5px",
  26. inline_code_radius: "0px",
  27.  
  28. comment_code_bgcol: "#eff0f1",
  29. comment_code_padding: "1px 5px",
  30. };
  31.  
  32. buildCSS();
  33. injectCSS();
  34.  
  35. function buildCSS(){
  36. var line_height = values.line_height;
  37.  
  38. // paragraphs (revert line-height)
  39. style += ".s-prose { line-height: " + line_height + "!important; }";
  40.  
  41. // ADDITIONAL REVERSIONS
  42. // code blocks
  43. style += ".s-prose pre:not(.s-code-block) { ";
  44. style += "background-color: " + values.code_block_bgcol + "!important;";
  45. style += "padding: " + values.code_block_padding + "!important;";
  46. style += "border-radius: " + values.code_block_radius + "!important;";
  47. style += "}";
  48.  
  49. // transparent bg on code lines within code blocks
  50. style += ".s-prose pre:not(.s-code-block) code { background-color: transparent!important; }";
  51.  
  52. // inline code
  53. style += ".s-prose code:not(.s-code-block) {";
  54. style += "background-color: " + values.inline_code_bgcol + "!important;";
  55. style += "padding: " + values.inline_code_padding + "!important;";
  56. style += "border-radius: " + values.inline_code_radius + "!important;";
  57. style += "}";
  58.  
  59. // comment inline code
  60. style += ".comment-text code {";
  61. style += "background-color: " + values.comment_code_bgcol + "!important;";
  62. style += "padding: " + values.comment_code_padding + "!important;"; // padding is same
  63. style += "}";
  64.  
  65. }
  66.  
  67. function injectCSS(){
  68. // credit: https://stackoverflow.com/a/13436780/3705191
  69. var cssStyle = document.createElement('style');
  70. cssStyle.type = 'text/css';
  71. var rules = document.createTextNode(style);
  72. cssStyle.appendChild(rules);
  73. document.getElementsByTagName("head")[0].appendChild(cssStyle);
  74. }
  75. })();