Trimmer for old Reddit
当前为
// ==UserScript==
// @name TrimOldReddit
// @namespace stgeorge
// @description Trimmer for old Reddit
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @match *://old.reddit.com/
// @match *://old.reddit.com/r/*
// @grant GM.xmlHttpRequest
// @version 0.1
// ==/UserScript==
(function() {
let side = $('.side');
function loadComment(u) {
console.log('LINK', u);
GM.xmlHttpRequest({
method: "GET",
url: u,
onload: function(response) {
side.html($.parseHTML(response.responseText));
let c = side.find('.content[role="main"]').detach();
side.empty();
c.appendTo(side);
c.css({margin:'10px'});
side.find('.infobar').detach();
}
});
}
function trim() {
let content = $('.content[role="main"]');
content.css({
width:'40%',
height: '1000px',
'overflow-y': 'auto',
margin:'5px',
});
$('.infobar').remove();
$('.footer-parent').remove();
side.empty();
side.css({
width:'59%',
margin:'5px',
height: '1000px',
'overflow-y': 'auto',
'padding-top': 0,
});
content.wrap('<div id="body-wrapper" style="display:flex"></div>');
side.appendTo('#body-wrapper');
$('.thing').hover(
function(e) {
let t = $(this);
if (!t.hasClass('clicked'))
t.css({'background-color':'#eeeeee'});
},
function(e) {
let t = $(this);
if (!t.hasClass('clicked'))
t.css({'background-color':'white'});
}
);
$('.entry a').each(function(k,v) {
var t = $(this).closest('.thing');
$(this).on('click', function(e) {
let href = $(this).attr('href');
if (href.indexOf('/comments/') != -1) {
t.css({'background-color':'#eeeeee'});
t.addClass('clicked');
t.siblings().css({'background-color':'white'});
t.siblings().removeClass('clicked');
e.preventDefault();
e.stopPropagation();
loadComment(href);
}
});
});
}
if (document.URL.indexOf('/comments/') != -1)
return;
trim();
})();