🏠 返回首頁 

Greasy Fork is available in English.

Expand Subreddit Header

Expand subreddit header on Reddit


安装此脚本?
  1. // ==UserScript==
  2. // @name Expand Subreddit Header
  3. // @version 0.5
  4. // @description Expand subreddit header on Reddit
  5. // @author Drazen Bjelovuk
  6. // @match *://www.reddit.com/*
  7. // @grant none
  8. // @run-at document-start
  9. // @namespace https://greasyfork.org/users/11679
  10. // @contributionURL https://goo.gl/dYIygm
  11. // ==/UserScript==
  12. var css = document.createElement("style");
  13. css.type = "text/css";
  14. css.innerHTML =
  15. "#sr-header-area .flat-list > li { white-space: initial !important; } " +
  16. "#sr-header-area .dropdown.srdrop { padding-left: 0 !important; }" +
  17. ".sr-list { display: inline !important; visibility: hidden; } " +
  18. "#sr-header-area { height: initial !important; } " +
  19. "#sr-header-area > .width-clip { position: initial !important; padding-left: 5px !important; } " +
  20. "#sr-more-link { position: initial !important; } " +
  21. ".dropdown.srdrop { display: none !important; }";
  22. document.head.appendChild(css);
  23. document.addEventListener("DOMContentLoaded", function() {
  24. var list = document.querySelectorAll('.sr-list')[0].children[2];
  25. var subs = list.children;
  26. subs[0].innerHTML = '<span class="separator">-</span>' + subs[0].innerHTML;
  27. var sorted = Array.prototype.slice.call(subs).sort(function(a, b) {
  28. return a.lastChild.textContent.toLowerCase() > b.lastChild.textContent.toLowerCase() ? 1 : -1;
  29. });
  30. var firstSeparator = sorted[0].getElementsByClassName('separator')[0];
  31. if (firstSeparator) firstSeparator.remove();
  32. sorted.forEach(function(node) {
  33. list.appendChild(node);
  34. });
  35. list.parentNode.style.visibility = 'visible';
  36. });