// ==UserScript== // @name Clear Placeholder on Baidu (Dynamic) // @namespace http://tampermonkey.net/ // @version 0.3 // @description 去除百度首页搜索框自动加载的热搜内容词条 // @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,立即清空 if (inputElement.placeholder) { inputElement.placeholder = ''; } // 使用 MutationObserver 监听 placeholder 的变化 var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { // 如果 placeholder 属性发生变化 if (mutation.type === 'attributes' && mutation.attributeName === 'placeholder') { // 清空 placeholder inputElement.placeholder = ''; } }); }); // 配置观察选项 var config = { attributes: true, // 监听属性变化 attributeFilter: ['placeholder'] // 只监听 placeholder 属性 }; // 开始观察输入框元素 observer.observe(inputElement, config); } })();