添加个性化按钮

在百度页面添加一个个性化按钮

目前为 2023-04-24 提交的版本。查看 最新版本

// ==UserScript==
// @name         添加个性化按钮
// @namespace    TechXueXi
// @version      1.0
// @description  在百度页面添加一个个性化按钮
// @author       huang
// @match        https://www.baidu.com/*
// @grant        none
// @license  none
// ==/UserScript==

(function() {
    'use strict';
setBut1();
setBut2();

//按键1
    function setBut1(){
        const button = document.createElement("button");
        button.innerHTML = "个性化按钮";
// Add styles to the button
button.style.borderRadius = "10px";
button.style.padding = "10px";
button.style.backgroundColor = "#4CAF50";
button.style.color = "black";
button.style.border = "2px solid #fffff";


        const baiduContainer = document.querySelector("#s-top-left");
        baiduContainer.insertBefore(button, baiduContainer.endChild);
    }
//按键2
    function setBut2(){
        let button = document.createElement("button");
        button.innerText = "个性化按钮2";
        button.style.padding = "8px 12px";
        button.style.backgroundColor = "#000";
        button.style.color = "#fff";
        button.style.borderRadius = "4px";
        button.style.border = "none";
        button.style.cursor = "pointer";
        button.style.position = "absolute";
        button.style.top = "50px";
        button.style.right = "50px";
        //document.body.appendChild(button);
        document.body.insertBefore(button, document.body.firstElementChild);
    }
})();