Bypass the "open in app prompt", unblur NSFW content and thumbnails, remove the blur from community highlight cards.
当前为
// ==UserScript==
// @name Reddit Bypass Enchancer
// @version 2.0
// @description Bypass the "open in app prompt", unblur NSFW content and thumbnails, remove the blur from community highlight cards.
// @author UniverseDev
// @license GPL-3.0-or-later
// @match https://www.reddit.com/*
// @match https://sh.reddit.com/*
// @grant none
// @run-at document-start
// @noframes
// @namespace https://greasyfork.org/en/users/1030895-universedev
// ==/UserScript==
'use strict';
(function () {
function queryElementsDeep(selector) {
const foundElements = new Set();
try {
const lightDomElements = document.querySelectorAll(selector);
lightDomElements.forEach(el => foundElements.add(el));
const allElements = document.querySelectorAll('*');
for (const el of allElements) {
if (el.shadowRoot) {
const shadowElements = el.shadowRoot.querySelectorAll(selector);
shadowElements.forEach(el => foundElements.add(el));
}
}
} catch (error) {
console.error("Error in queryElementsDeep:", error);
}
return Array.from(foundElements);
}
const SELECTORS = {
nsfwModal: `${'shreddit-async-loader'}[${'bundlename'}*="nsfw_blocking_modal"]`,
promptContainer: `${'xpromo-nsfw-blocking-container'} > *`,
prompt: '.prompt',
blurredContainer: 'shreddit-blurred-container',
thumbnailBlur: '.thumbnail-blur',
communityHighlightCard: 'community-highlight-card',
thumbnailImage: 'img.mb-0.h-full.w-full.object-cover',
thumbnailShadow: '.thumbnail-shadow',
mediaBackground: '.bg-media-background',
blurredSpan: 'span.inner.blurred',
scrim: '.absolute.top-0.left-0.w-full.h-full.bg-scrim',
imageFilter: 'img.mb-0.h-full.w-full.object-cover',
video: 'shreddit-player, video',
mediaTelemetryObserver: 'media-telemetry-observer',
mediaPlayerLoader: 'shreddit-async-loader[bundlename="media_player_loader"]',
shredditPlayer: 'shreddit-player',
outerContainer: 'div.outer.h-full',
badgeContainer: '.flex.items-center.gap-2xs.text-white',
clickedContainerClass: 'redditenhancer-clicked-container'
};
const BLURRED_TAG = SELECTORS.blurredContainer;
const MEDIA_TELEMETRY_OBSERVER_SELECTOR = SELECTORS.mediaTelemetryObserver;
const BADGE_CONTAINER = SELECTORS.badgeContainer;
const CLICKED_CONTAINER_CLASS = SELECTORS.clickedContainerClass;
function removeNSFWBlock() {
try {
const nsfwModal = document.querySelector(SELECTORS.nsfwModal);
if (nsfwModal) {
nsfwModal.remove();
}
const promptContainer = document.querySelector(SELECTORS.promptContainer);
let prompt = null;
if (promptContainer && promptContainer.shadowRoot) {
prompt = promptContainer.shadowRoot.querySelector(SELECTORS.prompt);
}
if (prompt) {
prompt.remove();
}
const blurredContainers = document.querySelectorAll(BLURRED_TAG);
blurredContainers.forEach(container => {
try {
if (container.shadowRoot?.innerHTML && container.firstElementChild) {
container.firstElementChild.addEventListener('click', function(e) {
e.preventDefault();
if (e.target.closest(MEDIA_TELEMETRY_OBSERVER_SELECTOR)) {
e.stopPropagation();
}
container.classList.add(CLICKED_CONTAINER_CLASS);
e.target.click();
}, { once: true });
container.firstElementChild.click();
}
} catch (error) {
console.error("Error processing blurred container:", error, container);
}
});
document.querySelectorAll(SELECTORS.thumbnailBlur).forEach(el => el.classList.remove('thumbnail-blur'));
document.querySelectorAll(SELECTORS.communityHighlightCard).forEach(card => card.removeAttribute('blurred'));
document.querySelectorAll(SELECTORS.imageFilter).forEach(img => img.style.removeProperty('filter'));
document.querySelectorAll(SELECTORS.video).forEach(video => {
video.classList.remove('blur');
});
const thumbnailShadow = document.querySelector(SELECTORS.thumbnailShadow);
if (thumbnailShadow) {
thumbnailShadow.remove();
}
const mediaBackground = document.querySelector(SELECTORS.mediaBackground);
if (mediaBackground) {
mediaBackground.style.backgroundColor = 'transparent';
}
queryElementsDeep(SELECTORS.blurredSpan).forEach(span => {
span.style.removeProperty('filter');
});
queryElementsDeep(SELECTORS.scrim).forEach(scrim => {
scrim.remove();
});
queryElementsDeep(BADGE_CONTAINER).forEach(badge => {
badge.remove();
});
}
catch (error) {
console.error("Error in removeNSFWBlock:", error);
}
}
const observer = new MutationObserver(removeNSFWBlock);
const contentContainer = document.documentElement;
observer.observe(contentContainer, {
childList: true,
subtree: true,
attributes: false
});
const shredditCheckInterval = setInterval(() => {
if (!document.querySelector('shreddit-app')) {
observer.disconnect();
clearInterval(shredditCheckInterval);
}
}, 5000);
})();