您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
主要平常搜索的时候大部分都是谷歌和百度,用其他的一些,支持的平台多,但是相应加载速度变慢,所以自己写了一个,有喜欢的小伙伴可以使用。
当前为
// ==UserScript== // @name 切换百度谷歌搜索引擎 // @namespace http://tampermonkey.net/ // @version 0.5 // @description 主要平常搜索的时候大部分都是谷歌和百度,用其他的一些,支持的平台多,但是相应加载速度变慢,所以自己写了一个,有喜欢的小伙伴可以使用。 // @author Blazing // @include *://*.google.*/search* // @match https://www.baidu.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=google.com.hk // @grant none // @license MIT // ==/UserScript== (function() { let domain = window.location.href; // 等待关键元素加载 function waitForKeyElements(selector, callback){ const el = document.querySelector(selector); if(el) { callback(el); } else { setTimeout(() => { waitForKeyElements(selector, callback); }, 100); } } if (domain.includes('baidu.com')) { waitForKeyElements('#kw', baiduElement => { let baiduValue = baiduElement.value; let div = document.querySelector('#s_tab div'); div.insertAdjacentHTML("afterbegin", ` <a href="https://www.google.com.hk/search?q=${baiduValue}" id="blazing-google">谷歌</a> `); }); } else if (domain.includes('google')) { waitForKeyElements('.nfdoRb .zItAnd', () => { insertGoogleLink(); }); } function insertGoogleLink() { let url = window.location.href; let domain = url.split('?')[0]; let query = url.split('?')[1]; let params = new URLSearchParams(query); let googleValue = params.get('q'); googleValue = googleValue.replaceAll(' ', '%20'); const firstLink = document.querySelector(".nfdoRb .zItAnd"); firstLink.insertAdjacentHTML('beforebegin', ` <a class="zItAnd FOU1zf" id="Blazingss" href="https://www.baidu.com/s?wd=${googleValue}"> <div class="O3S9Rb">百度</div> </a> `); } })();