sanereddit

Sanereddit will remove the sidebar/bloatbar on the right, and expand the linklist and comments to the appropriate width, allowing reddit to be used in a sane manner.

目前为 2016-01-20 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name sanereddit
  3. // @namespace sanereddit
  4. // @version 1
  5. // @grant none
  6. // @description Sanereddit will remove the sidebar/bloatbar on the right, and expand the linklist and comments to the appropriate width, allowing reddit to be used in a sane manner.
  7. // ==/UserScript==
  8. (function () {
  9. var sideBar = document.getElementsByClassName('side') [0];
  10. var linkList = document.getElementsByClassName('linklisting') [0];
  11. var commentarea = document.getElementsByClassName('commentarea')[0];
  12. var comments = document.getElementsByClassName('comment');
  13. var mds = document.getElementsByClassName('md');
  14. var root= document.compatMode=='BackCompat'? document.body : document.documentElement;
  15. function go() {
  16. sideBar.style.display = 'none';
  17. linkList.style.width = '100%';
  18. commentarea.style.width='100%';
  19. var i = 0;
  20. for (i = 0; i < comments.length; i++) {
  21. comments[i].style.width = '100%';
  22. }
  23. for (i = 0; i < mds.length; i++) {
  24. var elem = mds[i];
  25. var rect = elem.getBoundingClientRect();
  26. var marginRight = 10;
  27. elem.style.maxWidth = (root.clientWidth - rect.left - marginRight) + 'px';
  28. }
  29. }
  30. // Attach it the resize event
  31. window.addEventListener('resize', function (event) {
  32. go();
  33. });
  34. // Run it once initially
  35. go();
  36. }());