百度搜索跳转到google,快捷跳转
当前为
// ==UserScript==
// @name 百度搜索跳转到google
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 百度搜索跳转到google,快捷跳转
// @author You
// @match https://www.baidu.com/s?ie=UTF-8&wd=v2ex
// @match *://www.baidu.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=baidu.com
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
let parent = document.querySelectorAll("#su")[0].parentElement;
//position: relative;
parent.style.position = "relative";
//添加字节点
let child = document.createElement("div");
child.style.width = "80px";
child.style.height = "40px";
child.style.backgroundColor = "#5772e7";
child.style.display = "flex";
child.style.alignItems = "center";
child.style.justifyContent = "center";
child.style.borderRadius = "5px";
child.innerHTML = "GOOGLE";
child.style.marginLeft = "10px";
child.style.position = "absolute";
child.style.top = "0px";
child.style.right = "-100px";
child.style.color = "#fff";
child.style.cursor = "pointer";
child.style.fontSize = "14px";
child.style.boxShadow = "2px 5px 8px 0px rgb(0 0 0 / 37%)";
let inputWrapper = document.querySelectorAll("#kw")[0];
let inputValue = inputWrapper.value;
inputWrapper.addEventListener("input", function() {
inputValue = inputWrapper.value;
});
//点击事件
child.onclick = function() {
window.open("https://www.google.com/search?q=" + inputValue);
}
//添加到父节点
parent.appendChild(child);
})();