Greasy Fork

Greasy Fork is available in English.

图片全局模糊

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name            图片全局模糊
// @namespace       http://greasyfork.icu/zh-CN/users/1361855-fourth-master
// @version         1.0.1
// @description     一个用于给网站图片添加模糊效果的油猴脚本
// @author          Fourth_Master
// @match           *://*/*
// @require         https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/arrive/2.4.1/arrive.min.js
// @require         http://greasyfork.icu/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       http://greasyfork.icu/scripts/531690
// @supportURL      http://greasyfork.icu/scripts/531690
// @homepageURL     http://greasyfork.icu/scripts/531690
// ==/UserScript==

(function() {
  'use strict';

  // 获取更新时间
  function getUpdateTime(timestamp) {
    return timestamp ? (' (更新于: ' + new Date(timestamp).toLocaleDateString() + ')') : '';
  }

  const style = {
    // 设置面板样式
    settings: `
#myGoodBoyConfig {
  --primary: #4A90E2;
  --text: #333;
  --bg: #FFF;
  --border: #E0E0E0;
  font-family: system-ui, sans-serif;
  line-height: 1.6;
}

#myGoodBoyConfig .section_header {
  padding: 1rem;
  background: var(--primary);
  border-radius: 0.4rem;
}

#myGoodBoyConfig input[type="checkbox"] {
  width: 1.2em;
  height: 1.2em;
}

#myGoodBoyConfig button {
  padding: 0.6em 1.2em;
  border-radius: 0.4em;
  transition: opacity 0.2s;
}

#myGoodBoyConfig button:hover {
  opacity: 0.9;
}
`,
  };

  // 初始化配置
  GM_config.init({
      'id': 'myGoodBoyConfig',
      'title': GM_config.create('a', {
        'textContent': '图片全局模糊-设置 ver.' + GM_info.script.version,
        'title': '点击跳转到脚本页面' + getUpdateTime(GM_info.script.lastModified),
        'target': '_blank',
        'href': 'https://sleazyfork.org/zh-CN/scripts/531690',
      }),
      'skin': 'tab',
      'css': style.settings,
      'frameStyle': {
        'width': '400px',
        'height': '350px',
      },
      'fields': {
          'blurEnable': {
            'section': GM_config.create('a', {
              textContent: '作者: Fourth_Master',
              title: '点击反馈问题',
              target: '_blank',
              href: 'https://blog.soeg.cn/',
            }),
              '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();
})();