There are 8 previous versions of this script.
// ==UserScript==
// @name Reddit fixer
// @namespace
// @description Clean up Reddit pages to be a little nicer, like old Reddit
// @include http://reddit.com/*
// @include http://*.reddit.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// ==/UserScript==
// Reddit fixer
// version 1.1.2 (2009-10-11)
// Copyright (c) Dan Fenwick, licensed under BSD
var unwanted = (['infobar', 'side', 'footer-parent', 'midcol', 'rank',
'thumbnail', 'tagline', 'organic-listing', 'promotedlink',
'arrow up','arrow down','searchpane raisedbox','description',
'expando-button', 'expando'
]); // some of these are often duplicates, but not always
var delete_count = 0;
function xpath(exp) {
// build, count, kill elements in XPath result set
var i, item;
var result = document.evaluate(exp,
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (i = 0; item = result.snapshotItem(i); i++) {
item.parentNode.removeChild(item);
delete_count++;
}
}
function killElementsByClass(classes) {
// generic by-class XPath search
var i, len;
// seek string ' TARGET ' in ' FULL CLASSNAME '
for (i = 0, len = classes.length; i < len; i++) {
xpath('//*[contains(concat(" ", @class, " "), " ' + classes[i] + ' ")]');
}
}
// implement the 'hide/show comments links' menu command
// this uses JQuery as provided by Google (http://code.google.com/apis/ajaxlibs/)
function commentToggle() {
$("li.first").toggle();
}
// collapse the three-line block elements into an inline run-on via CSS
sheet = document.styleSheets[document.styleSheets.length - 1];
sheet.insertRule('p.title, p.nextprev, p.titlerow, ul.flat-list, a.comments {display:inline; margin-left:0; margin-right:0.5em};', sheet.length);
sheet.insertRule('.md p,.md h1 {margin: 0 0 5px 0 !important};', sheet.length);
sheet.insertRule('div.md p + p {margin-top: 1px !important};', sheet.length);
sheet.insertRule('.midcol, .tagline {display: none !important};', sheet.length);
sheet.insertRule('.entry div .buttons li {display: none};', sheet.length);
// add a link to the subreddits page to replace the deleted sidebar one
link = document.createElement('a');
link.setAttribute('href', '/reddits/');
link.appendChild(document.createTextNode('/reddits/'));
// add a shortcut link to show/hide comments links
comment = document.createElement('a');
comment.setAttribute('href', 'javascript:void()');
comment.setAttribute('onclick', '$("li.first").toggle();');
comment.appendChild(document.createTextNode('comments'));
nextprev = document.getElementById('siteTable').parentNode.lastChild;
nextprev.appendChild(document.createTextNode('\n|\n'));
nextprev.appendChild(link);
nextprev.appendChild(document.createTextNode('\n|\n'));
nextprev.appendChild(comment);
// register link, 'shared' links, and reddits header
xpath('//div[@id = "header-bottom-right"]/*');
xpath('//ul[@class = "flat-list buttons"]/li[not(@class = "first")]');
xpath('//div[@id = "sr-header-area"]');
// move search box
document.getElementById('header-bottom-right').appendChild(
document.getElementById('search'));
// toast elements with generic class query
killElementsByClass(unwanted);
// add mouse-over "# deleted" to reddit image in top left corner
document.getElementById('header-img').title = delete_count + " deleted";
// hide the comments links and add a command to restore them to view
$("li.first").hide();
GM_registerMenuCommand('Show/hide comment links', commentToggle);
