百度搜索跳转到google

百度搜索跳转到google,快捷跳转

当前为 2023-05-10 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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);
})();