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

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

📂 缓存分发状态(共享加速已生效)
🕒 页面同步时间:2025/12/26 19:15:29
🔄 下次更新时间:2025/12/26 20:15:29
手动刷新缓存

Search-Block

自动屏蔽搜索结果中某些网站,比如 CSDN

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         Search-Block
// @namespace    https://greasyfork.org/zh-CN/users/874463
// @version      0.1.2
// @description  自动屏蔽搜索结果中某些网站,比如 CSDN

// @match        *://www.google.com/search*
// @match        *://www.google.com.hk/search*
// @match        *://www.baidu.com/s*
// @match        *://www.baidu.com/$
// @icon         https://s3.bmp.ovh/imgs/2022/02/b5ded49cff4df12d.png
// @grant        none

// @author       Uyloal
// @license      MIT
// @code         https://github.com/uyloal/search-block
// @date         2022-02-09
// ==/UserScript==

(function () {
  ("use strict");
  // 配置各站点的 feed
  // feedSelector: 想要选中的 Tag
  // rule: 自定义的规则
  var baseConfig = {
    "www.baidu.com": {
      feedSelector: "input.s_ipt",
      rule: "-csdn",
    },
    "www.google.com": {
      feedSelector: "input.gLFyf.gsfi",
      rule: "-csdn",
    },
    "www.google.com.hk": {
      feedSelector: "input.gLFyf.gsfi",
      rule: "-csdn",
    },
  };
  var host = window.location.host;
  var config = baseConfig[host];
  var input = document.querySelector(config.feedSelector);
  if (input) {
    input.addEventListener("keydown", function (e) {
      if (
        e.key == "Enter" &&
        this.value.length > 0 &&
        this.value.indexOf(config.rule) == -1
      ) {
        this.value += " " + config.rule;
      }
    });
    input.addEventListener("blur", function () {
      if (this.value.length > 0 && this.value.indexOf(config.rule) == -1) {
        this.value = this.value + " " + config.rule;
      }
    });
    input.addEventListener("focus", function () {
      var index = this.value.indexOf(" " + config.rule);
      if (index != -1) {
        this.value = this.value.substring(0, index);
      }
    });
  }
})();