Single Line Scrollbars

Fixes appearance of single-line code blocks so that OS X's scrollbars don't block the text within

  1. // ==UserScript==
  2. // @name Single Line Scrollbars
  3. // @author Cameron Bernhardt (AstroCB)
  4. // @description Fixes appearance of single-line code blocks so that OS X's scrollbars don't block the text within
  5. // @namespace http://github.com/AstroCB
  6. // @version 1.0
  7. // @include http://*.stackexchange.com/*
  8. // @include http://stackoverflow.com/*
  9. // @include http://meta.stackoverflow.com/*
  10. // @include http://serverfault.com/*
  11. // @include http://meta.serverfault.com/*
  12. // @include http://superuser.com/*
  13. // @include http://meta.superuser.com/*
  14. // @include http://askubuntu.com/*
  15. // @include http://meta.askubuntu.com/*
  16. // @include http://stackapps.com/*
  17. // ==/UserScript==
  18. var codeBlocks = document.getElementsByTagName("code");
  19.  
  20. for (var i = 0; i < codeBlocks.length; i++) {
  21. console.log(codeBlocks[i].textContent.split("\n"));
  22. if (codeBlocks[i].textContent.split("\n").length < 3) { // No newlines
  23. codeBlocks[i].setAttribute("style", "line-height: 35px;");
  24. }
  25. }