// ==UserScript== // @name Replace Google logo with Baidu // @name:zh-CN 将 Google Logo 替换为百度 // @namespace http://tampermonkey.net/ // @version 0.4 // @description Replace Google logo in homepage with Baidu logo // @description:zh-CN 将 Google 首页的 Logo 替换为相同 Google 配色的百度 Logo // @author ReekyStive // @match https://www.google.com/ // @match https://www.google.com.*/ // @match https://www.google.com/webhp?* // @match https://www.google.com.*/webhp?* // @icon https://www.google.com/favicon.ico // @grant none // @run-at document-start // @license MIT // @downloadURL none // ==/UserScript== (function () { 'use strict'; if (!(window.location.pathname === '/' || window.location.pathname === '/webhp')) { return; } // this logo is copyrighted to Baidu and modified by ReekyStive const baiduSvgOuterHtml = ""; const style = document.createElement('style'); style.innerHTML = ".lnXdpd { display: none; }"; document.head.appendChild(style); const domContentLoadedHandler = () => { const logo = document.querySelector('.lnXdpd'); const attributes = logo .getAttributeNames() .filter(name => name !== 'viewBox') .map((name) => [name, logo.getAttribute(name)]); const template = document.createElement('template'); template.innerHTML = baiduSvgOuterHtml; const baiduSvgNode = template.content.firstElementChild; attributes.forEach(([name, value]) => { baiduSvgNode.setAttribute(name, value); }) logo.replaceWith(baiduSvgNode); document.head.removeChild(style); console.log('Replaced Google Logo!'); const googleSearchButton = document.querySelector('.FPdoLc.lJ9FBc input.gNO89b'); const googleSearchButtonContent = googleSearchButton.getAttribute('value'); googleSearchButton.setAttribute('value', googleSearchButtonContent.replaceAll('Google', 'Baidu')); }; window.addEventListener('DOMContentLoaded', domContentLoadedHandler); })();