Reddit Inline Gallery

Add's inline gallery viewmode on reddit.com

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name           Reddit Inline Gallery
// @namespace      http://google.dcom
// @description    Add's inline gallery viewmode on reddit.com
// @version        1.2
// @include        http://www.reddit.com/*
// @include        http://*.reddit.com/*
// @exclude        http://www.reddit.com/ads/*
// @require 	   http://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.min.js
// ==/UserScript==
//

(function() {
  $('head').append('<link rel="stylesheet" type="text/css" href="http://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.css">');

  $('#siteTable div.entry').each(function(index) {
    var gallink = $(this).find('p.title a.title').clone();
    gallink.addClass('fancybox');gallink.removeClass('title');gallink.removeClass('may-blank');
    gallink.attr('data-fancybox-group', 'gallery');
    gallink.attr('title', gallink.html());
    gallink.html('open gallery');

    var extension = gallink.attr('href').substr((gallink.attr('href').lastIndexOf('.') +1));
    if (extension != 'jpg' && gallink.attr('href').indexOf('imgur') != -1) {
      gallink.attr('href', gallink.attr('href') + '.jpg');
      var extension_force = true;
    }

    if (extension == 'jpg' || extension_force == true) {
      $(this).find('ul.flat-list').append('<li>' + gallink.get(0).outerHTML + '</li>');
    }
  });

  $(".fancybox").fancybox({
    openEffect  : 'none',
    closeEffect : 'none'
  });
})();