Expand subreddit header on Reddit
当前为
// ==UserScript==
// @name Expand Subreddit Header
// @version 0.2
// @description Expand subreddit header on Reddit
// @author Josh Bjelovuk
// @match *://www.reddit.com/*
// @grant none
// @run-at document-start
// @namespace https://greasyfork.org/users/11679
// ==/UserScript==
var css = document.createElement("style");
css.type = "text/css";
css.innerHTML =
"#sr-header-area .flat-list > li { white-space: initial; } " +
"#sr-header-area .dropdown.srdrop { padding-left: 0 }" +
".sr-list { display: inline; visibility: hidden } " +
"#sr-header-area { height: initial; } " +
"#sr-header-area > .width-clip { position: initial; padding-left: 5px } " +
"#sr-more-link { position: initial; } " +
".dropdown.srdrop { display: none; }";
document.head.appendChild(css);
document.addEventListener("DOMContentLoaded", function() {
var list = document.querySelectorAll('.sr-list')[0].children[2];
var subs = list.children;
subs[0].innerHTML = '<span class="separator">-</span>' + subs[0].innerHTML;
var sorted = Array.prototype.slice.call(subs).sort(function(a, b) {
return a.lastChild.textContent.toLowerCase() > b.lastChild.textContent.toLowerCase() ? 1 : -1;
});
var firstSeparator = sorted[0].getElementsByClassName('separator')[0];
if (firstSeparator) firstSeparator.remove();
sorted.forEach(function(node) {
list.appendChild(node);
});
list.parentNode.style.visibility = 'visible';
});