// ==UserScript== // @name 双搜索引擎 // @namespace Violentmonkey Scripts // @match https://www.google.com/search // @match https://www.baidu.com/s // @grant none // @version 1.0 // @author - // @description 2021/1/4 上午10:33:27 // @downloadURL none // ==/UserScript== if (window.location.hostname === "www.google.com") { const box = document.querySelector("div.RNNXgb[jsname='RNNXgb']"); const input = document.querySelector("input[aria-label='搜索']"); const btn = document.createElement('button'); btn.className = 'Tg7LZd' btn.ariaLabel = '百度搜索' btn.onclick = () => { window.open(`https://www.baidu.com/s?wd=${input.value}`) } btn.innerHTML = `
` box.appendChild(btn) } else if (window.location.hostname === "www.baidu.com") { const su = document.getElementById('su') su.style = 'border-radius: 0' const input = document.createElement('input') const kw = document.getElementById('kw') input.style = ` float: right; cursor: pointer; width: 60px; height: 40px; line-height: 41px; line-height: 40px\\9; background-color: #4e6ef2; border-radius: 0 10px 10px 0; font-size: 17px; box-shadow: none; font-weight: 400; border: 0; outline: 0; letter-spacing: normal; color: #ffffff; ` input.type = 'submit' input.value = '谷歌' input.onclick = () => { window.open(`http://www.google.com/search?q=${kw.value}`) } const box = su.parentNode box.style.width = box.offsetWidth + 60 + 'px' box.appendChild(input) }