您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
View inline Reddit threads from the front page or any subreddit.
当前为
// ==UserScript== // @name Reddit Inline Comments Viewer // @namespace http://reddit.com // @version 0.12 // @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== $(document).ready(function($){ $('div>div>ul>li:nth-child(1)>a').each(function(i) { var post = $(this).parents().eq(3); $('<li class="site-viewer-' + i + '"><a href="#">view thread</a><li>').insertAfter(post.find('ul>li:nth-child(5)')); var insertButton = function(){ $('<button class="inline-next-post" 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').hide(); }); }; $('.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').hide(); } else { if (post.find('div.commentarea').length > 0) { $('.site-viewer-' + i + '>a').text('close thread'); post.find('button').show(); 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() { $('.site-viewer-' + i + '>a').text('close thread'); if ($('.inline-next-post').length > 0) { $('.inline-next-post').hide(); } insertButton(); iframe.contents().find('div.commentarea').appendTo(post); iframe.remove(); }); } } }.bind(this)); }); });