🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Reddit Search Image Tab Enhancer: Unblur and Remove Scrim

Unblur and remove background scrim on new elements, including those in shadow DOMs, on Reddit search results

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         Reddit Search Image Tab Enhancer: Unblur and Remove Scrim
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Unblur and remove background scrim on new elements, including those in shadow DOMs, on Reddit search results
// @author       Devon Lark
// @match        https://www.reddit.com/search/*
// @grant        none
// ==/UserScript==

(function() {
  'use strict';

  function processElement(element) {
      if (element.tagName === 'SPAN' && element.getAttribute('style') === "filter:blur(40px);" && !element.dataset.processed) {
          element.style.filter = '';
          element.dataset.processed = 'true';
      }
      if (element.tagName === 'DIV' && element.getAttribute('class') === "absolute top-0 left-0 w-full h-full bg-scrim" && !element.dataset.processed) {
          element.remove();
          element.dataset.processed = 'true';
      }

      if (element.shadowRoot) {
          Array.from(element.shadowRoot.querySelectorAll('span:not([data-processed]), div:not([data-processed])'))
              .forEach(processElement);
      }
  }

  function processNewElements() {
      const elements = document.querySelectorAll('body *');
      elements.forEach(element => {
          processElement(element);
          if (element.shadowRoot) {
              Array.from(element.shadowRoot.querySelectorAll('span:not([data-processed]), div:not([data-processed])'))
                  .forEach(processElement);
          }
      });
  }

  const observer = new MutationObserver((mutations) => {
      mutations.forEach((mutation) => {
          if (mutation.type === 'childList') {
              processNewElements();
          }
      });
  });

  observer.observe(document.body, { childList: true, subtree: true });
})();