Greasy Fork

图片全局模糊

一个用于给网站图片添加模糊效果的油猴脚本

目前为 2025-04-03 提交的版本。查看 最新版本

// ==UserScript==
// @name            图片全局模糊
// @namespace       https://greasyfork.org/zh-CN/users/1361855-fourth-master
// @version         1.0.0
// @description     一个用于给网站图片添加模糊效果的油猴脚本
// @author          Fourth_Master
// @match           *://*/*
// @require         https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/arrive/2.4.1/arrive.min.js
// @require         https://greasyfork.org/scripts/403716-gm-config-cn/code/GM_config_CN.js
// @grant           GM_info
// @grant           GM_getValue
// @grant           GM_setValue
// @grant           GM_registerMenuCommand
// @grant           GM_addStyle
// @run-at          document-start
// @noframes
// @license         GNU General Public License v3.0 or later
// @namespace       https://greasyfork.org/scripts/*
// @supportURL      https://greasyfork.org/scripts/*
// @homepageURL     https://greasyfork.org/scripts/*
// ==/UserScript==

(function() {
  'use strict';
  
  // 初始化配置
  GM_config.init({
      'id': 'myGoodBoyConfig',
      'title': '图片全局模糊-设置',
      'fields': {
          'blurEnable': {
              'label': '启用图片模糊效果',
              'type': 'checkbox',
              'default': false
          },
          'blurRadius': {
              'label': '模糊半径',
              'type': 'int',
              'min': 1,
              'max': 20,
              'default': 10
          }
      }
  });

  // 添加模糊效果
  function applyBlurEffect() {
      if (!GM_config.get('blurEnable')) return;
      
      const blurRadius = GM_config.get('blurRadius');
      const style = `
          img {
              filter: blur(${blurRadius}px);
              transition: filter 0.3s;
          }
          img:hover {
              filter: blur(0);
          }
      `;
      
      GM_addStyle(style);
  }

  // 注册菜单命令
  GM_registerMenuCommand('图片全局模糊 - 设置', () => GM_config.open());

  // 初始化
  applyBlurEffect();
})();