View inline Reddit threads from the front page or any subreddit.
当前为
// ==UserScript==
// @name Reddit Inline Comments Viewer
// @namespace http://reddit.com
// @version 0.8
// @description View inline Reddit threads from the front page or any subreddit.
// @author jaszhix
// @match http*://www.reddit.com/*
// @exclude http*://www.reddit.com/*/*/comments/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @run-at document-end
// ==/UserScript==
$('div>div>ul>li:nth-child(1)>a').each(function(i) {
var post = $(this).parents().eq(3);
var insertButton = function(){
$('<button style="position: fixed; top: 95%; left: 85%;">Next Post</button>').insertAfter(post.find('ul>li:nth-child(6)'));
post.find('button').click(function() {
$('.site-viewer-' + ++i).get(0).scrollIntoView();
post.find('button').remove();
}.bind(this));
}.bind(this);
$('<li class="site-viewer-' + i + '"><a href="#">view thread</a><li>').insertAfter(post.find('ul>li:nth-child(5)'));
$('.site-viewer-' + i).click(function(e) {
e.preventDefault();
e.stopPropagation();
if ($('.site-viewer-' + i + '>a').text() === 'close thread') {
$('.site-viewer-' + i + '>a').text('view thread');
post.find('div.commentarea').hide();
post.find('button').detach();
} else {
if (post.find('div.commentarea').length > 0) {
insertButton();
$('.site-viewer-' + i + '>a').text('close thread');
post.find('div.commentarea').show();
} else {
$('.site-viewer-' + i + '>a').text('loading...');
$('<iframe />').attr({
'src': $(this).attr('href'),
'frameborder': '0',
'width': window.innerWidth / 1.2,
'height': window.innerHeight
}).appendTo(post);
var iframe = post.find('iframe');
iframe.hide();
iframe.on('load', function() {
insertButton();
$('.site-viewer-' + i + '>a').text('close thread');
iframe.contents().find('div.commentarea').appendTo(post);
iframe.remove();
}.bind(this));
}
}
}.bind(this));
});
// ==UserScript==
// @name Reddit Inline Comments Viewer
// @namespace http://reddit.com
// @version 0.7
// @description View inline Reddit threads from the front page or any subreddit.
// @author jaszhix
// @match http*://www.reddit.com/*
// @exclude http*://www.reddit.com/*/*/comments/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @run-at document-end
// ==/UserScript==
$('div>div>ul>li:nth-child(1)>a').each(function(i) {
var post = $(this).parents().eq(3);
var insertButton = function(){
$('<button style="position: fixed; top: 95%; left: 85%;">Next Post</button>').insertAfter(post.find('ul>li:nth-child(6)'));
post.find('button').click(function() {
$('.site-viewer-' + ++i).get(0).scrollIntoView();
post.find('button').remove();
}.bind(this));
}.bind(this);
$('<li class="site-viewer-' + i + '"><a href="#">view thread</a><li>').insertAfter(post.find('ul>li:nth-child(5)'));
$('.site-viewer-' + i).click(function(e) {
e.preventDefault();
e.stopPropagation();
if ($('.site-viewer-' + i + '>a').text() === 'close thread') {
$('.site-viewer-' + i + '>a').text('view thread');
post.find('div.commentarea').hide();
post.find('button').detach();
} else {
if (post.find('div.commentarea').length > 0) {
insertButton();
$('.site-viewer-' + i + '>a').text('close thread');
post.find('div.commentarea').show();
} else {
$('.site-viewer-' + i + '>a').text('loading...');
$('<iframe />').attr({
'src': $(this).attr('href'),
'frameborder': '0',
'width': window.innerWidth / 1.2,
'height': window.innerHeight
}).appendTo(post);
var iframe = post.find('iframe');
iframe.hide();
iframe.on('load', function() {
insertButton();
$('.site-viewer-' + i + '>a').text('close thread');
iframe.contents().find('div.commentarea').appendTo(post);
iframe.remove();
}.bind(this));
}
}
}.bind(this));
});