// ==UserScript== // @name 去除百度首页搜索框自动加载的热搜内容词条 // @namespace http://tampermonkey.net/ // @version 0.9 // @description 去除百度首页搜索框自动加载的热搜内容词条,快速清空 placeholder,避免可见的加载瞬间 // @author Your Name // @match https://www.baidu.com/ // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 获取百度搜索框元素 var inputElement = document.getElementById('kw'); // 百度搜索框的 ID 是 'kw' if (inputElement) { // 提前清空 placeholder inputElement.placeholder = ''; // 使用 MutationObserver 监控 placeholder 的变化 var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.type === 'attributes' && mutation.attributeName === 'placeholder') { // 如果 placeholder 被动态加载,立即清空 inputElement.placeholder = ''; observer.disconnect(); // 停止监控,避免重复清空 } }); }); // 配置 MutationObserver,监控 placeholder 属性的变化 var config = { attributes: true, // 监控属性变化 attributeFilter: ['placeholder'] // 只监控 placeholder 属性 }; // 开始监控 observer.observe(inputElement, config); } })();