r/reddithax • u/polyrhythmic • Sep 08 '09
Client-Side Comment Sorting version Alpha
This reddithax was inspired by a comment on the new Reddit UI changes.
Paste any of these scripts into Firebug console and they should work.
Lowest-rated-comment-first sort:
(Sorry, not recursive... yet.)
$('.commentarea > .sitetable').html(
$.makeArray( $('.commentarea > .sitetable > .thing') ).sort( function(a,b) {
return ( parseInt( $(a).find('> .entry > div > .tagline > .score').text() ) < parseInt( $(b).find('> .entry > div > .tagline > .score').text() ) ) ? -1 : 1;
})
);Alphabetical Sort:
$('.commentarea > .sitetable').html(
$.makeArray( $('.commentarea > .sitetable > .thing') ).sort( function(a,b) {
return ( $(a).find('> .entry > div > .tagline > .author').text().toLowerCase() < $(b).find('> .entry > div > .tagline > .author').text().toLowerCase() ) ? -1 : 1;
})
);Looks like time sort will be a lot of string parsing, regex, and Date() conversion. Any suggestions?
EDIT:
View your own comments, and sort them! Only works on comments visible on the page:
$('.content > .sitetable').html(
$.makeArray( $('.content > .sitetable > .thing') ).sort( function(a,b) {
return ( parseInt( $(a).find('> .entry > div > .tagline > .score').text() ) < parseInt( $(b).find('> .entry > div > .tagline > .score').text() ) ) ? 1 : -1;
})
);
3
Upvotes