Reddit Inline Comments Viewer

View inline Reddit threads from the front page or any subreddit.

2015-12-11 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Reddit Inline Comments Viewer
// @namespace    http://reddit.com
// @version      0.3
// @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) {
  $('<li class="site-viewer-' + i + '"><a href="#">view thread</a><li>').insertAfter($(this).parents().eq(3).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');
      $(this).parents().eq(3).find('div.commentarea').hide();
    } else {
      if ($(this).parents().eq(3).find('div.commentarea').length > 0) {
        $('.site-viewer-' + i + '>a').text('close thread');
        $(this).parents().eq(3).find('div.commentarea').show();
      } else {
        $('.site-viewer-' + i + '>a').text('loading...');
        console.log(e)
        $('<iframe />').attr({
          'src': $(this).attr('href'),
          'frameborder': '0',
          'width': window.innerWidth / 1.2,
          'height': window.innerHeight
        }).appendTo($(this).parents().eq(3));
        $(this).parents().eq(3).find('iframe').hide();
        $(this).parents().eq(3).find('iframe').on('load', function() {
          $('.site-viewer-' + i + '>a').text('close thread');
          $(this).parents().eq(3).find('iframe').contents().find('div.commentarea').appendTo($(this).parents().eq(3));
        }.bind(this));
      } 
    }
  }.bind(this));
});