Greasy Fork

Greasy Fork is available in English.

Remove Reddit Login Requirement

Remove the on-screen modal that forces you to log in for certain posts.

当前为 2023-11-17 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Remove Reddit Login Requirement
// @namespace    socuul.reddit_rem_loginreq
// @version      1.0.5
// @description  Remove the on-screen modal that forces you to log in for certain posts.
// @author       SoCuul
// @license      MIT
// @match        http://*.reddit.com/*
// @match        https://*.reddit.com/*
// @icon         https://reddit.com/favicon.ico
// @grant        GM_addStyle
// ==/UserScript==

(function() {

    const nsfwBlurredContainer = document.querySelector('shreddit-blurred-container')?.shadowRoot?.firstElementChild
    nsfwBlurredContainer?.setAttribute('class', nsfwBlurredContainer.attributes?.getNamedItem('class')?.nodeValue?.replace(/xs:rounded-t-\[16px\] xs:rounded-b-\[16px\]/g, ''))

    const mainContent = document.querySelector('.sidebar-grid')
    mainContent?.setAttribute('style', mainContent.attributes?.getNamedItem('style')?.nodeValue?.replace(/filter: blur\(4px\);/g, ''))

    const nsfwBlockingModal = document.querySelector('xpromo-nsfw-blocking-modal-desktop')
    nsfwBlockingModal?.remove()

    // Disable scroll prevention
    const body = document.querySelector('body')
    body?.setAttribute('style', body.attributes?.getNamedItem('style')?.nodeValue?.replace(/pointer-events: none; overflow: hidden;/g, ''))

    //Remove other elements
    const observerOptions = { subtree: true, childList: true }
    const mObserver = new MutationObserver(function() {

        const nsfwBlockingBypassableModal = document.querySelector('xpromo-nsfw-bypassable-modal-desktop')
        nsfwBlockingBypassableModal?.remove()

        const nsfwBlockingContainer = document.querySelector('xpromo-nsfw-blocking-container')?.shadowRoot?.querySelector('.prompt')
        nsfwBlockingContainer?.remove()

        // Remove inline blur
        document.querySelector('shreddit-blurred-container').shadowRoot.firstElementChild.firstElementChild.style = ''

        // Change image urls to remove blur
        //const blurredImgs = document.querySelector('shreddit-blurred-container')?.firstElementChild?.firstElementChild?.children
        //for (const el of blurredImgs) {
        //    el.src = el.src.replace(/preview.redd.it/g, 'i.redd.it')
        //}

    })

    mObserver.observe(document, observerOptions)

})();