Greasy Fork

Greasy Fork is available in English.

Reddit spoiler blur remover

Remove all blur on spoiler images while keeping the NSFW setting. Supports external images too.

当前为 2020-11-16 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Reddit spoiler blur remover
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Remove all blur on spoiler images while keeping the NSFW setting. Supports external images too.
// @author       violhain
// @match        https://*.reddit.com/*
// @grant        none
// @require http://code.jquery.com/jquery-latest.min.js
// ==/UserScript==

// Prevents script to load twice as Reddit uses iframes
if (window.top != window.self) { return false; }

(function() {
    'use strict';
    /* globals $ */

    $(document).ready(function() {
        console.log('Spoiler reveal activated');

        const reveal = () => {
            $('div.Post').each(function() {
                // Ignore NSFW posts
                if (!$(this).text().match(/nsfw/)) {
                    // Click on the spoiler reveal on individual posts
                    $(this).find('button:contains("spoiler")').parent().siblings('a').find('*').click();
                    let postImg = $(this).find('img[alt="Post image"]');
                    // Checks if the post is a spoiler
                    if (postImg.attr('src') && postImg.attr('src').match(/blur/)) {
                        // Checks if the image is external, replace the image without blur
                        if ($(this).find('a.styled-outbound-link').attr('href') && $(this).find('a.styled-outbound-link').attr('href').match(/\.(jpg|png)$/).length > 0) {
                            postImg.attr('src', $(this).find('a.styled-outbound-link').attr('href')).css('width','auto').css('height','auto');
                        } else {
                            postImg.attr('src', postImg.attr('src').replace('/preview','/i'));
                        }
                        // Remove blur CSS filter
                        postImg.css('filter','none');
                    }
                }
            });
        }

        reveal();
        window.onscroll = function(ev) {
            reveal();
        };
    });

})();