您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
在Google搜索栏右侧添加放大镜图标,点击后触发搜索操作。
// ==UserScript== // @name Google搜索栏添加放大镜图标(自用) // @namespace http://tampermonkey.net/ // @version 1.0 // @description 在Google搜索栏右侧添加放大镜图标,点击后触发搜索操作。 // @author Jinyou // @license MIT // @match https://www.google.com/* // @icon https://www.google.com/favicon.ico // @grant none // ==/UserScript== (function () { 'use strict'; // 添加 Google Fonts 的 Material Symbols 字体 const fontLink = document.createElement('link'); fontLink.href = 'https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined'; fontLink.rel = 'stylesheet'; document.head.appendChild(fontLink); // 等待页面加载完成 window.addEventListener('load', function () { // 获取搜索框的父元素 const searchBoxContainer = document.querySelector('.RNNXgb'); if (!searchBoxContainer) return; // 创建放大镜按钮 const magnifyingGlassBtn = document.createElement('button'); magnifyingGlassBtn.style.cssText = ` background: none; border: none; cursor: pointer; margin-left: 8px; padding: 4px; display: flex; align-items: center; justify-content: center; font-family: 'Material Symbols Outlined'; font-size: 24px; `; // 插入 Material Symbols 图标 magnifyingGlassBtn.innerHTML = '<span class="material-symbols-outlined">search</span>'; // 为按钮添加点击事件 magnifyingGlassBtn.addEventListener('click', function () { const searchInput = document.querySelector('input[name="q"]'); if (searchInput) { // 模拟搜索操作 searchInput.form.submit(); } }); // 将按钮添加到搜索框的右侧 searchBoxContainer.appendChild(magnifyingGlassBtn); }); })();