一键隐藏csdn搜索框!

按下按钮一键隐藏csdn搜索框,帮您沉浸式学习当前页面内容

目前為 2022-03-25 提交的版本,檢視 最新版本

// ==UserScript==
// @name        一键隐藏csdn搜索框!
// @namespace    http://tampermonkey.net/
// @version      0.31
// @description  按下按钮一键隐藏csdn搜索框,帮您沉浸式学习当前页面内容
// @author       Onion
// @include      *://blog.csdn.net/*/article/details/*
// @include      *.blog.csdn.net/article/details/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
        var button_1 = document.createElement("button"); //创建一个按钮
            button_1.textContent = "隐藏"; //按钮内容
            button_1.style.width = "80px"; //按钮宽度
            button_1.style.height = "28px"; //按钮高度
            button_1.style.align = "center"; //居中
            button_1.style.color = "#white"; //按钮文字颜色
            button_1.style.background = "#ffc0cb"; //按钮底色
            button_1.addEventListener("click", clickButton_1)

        var button_2 = document.createElement("button"); //创建第二个按钮
            button_2.textContent = "显现"; //按钮内容
            button_2.style.width = "80px"; //按钮宽度
            button_2.style.height = "28px"; //按钮高度
            button_2.style.align = "center"; //居中
            button_2.style.color = "#white"; //按钮文字颜色
            button_2.style.background = "#ffc0cb"; //按钮底色
            button_2.addEventListener("click", clickButton_2)

                function clickButton_1()
            {
                setTimeout(function() {
                    document.getElementById('toolbar-search-input').style.visibility = 'hidden';
                    document.getElementById('toolbar-search-button').style.visibility = 'hidden';

                 }, 100);// 100ms后执行

            }
               function clickButton_2()
            {
                setTimeout(function() {
                    document.getElementById('toolbar-search-input').style.visibility = 'visible';
                    document.getElementById('toolbar-search-button').style.visibility = 'visible';

                }, 100);// 100ms后执行

            }

    var toolboxclass = document.getElementsByClassName('toolbox-list')[0];
    toolboxclass.appendChild(button_1);
    toolboxclass.appendChild(button_2);//添加到子列
    var x = document.getElementsByClassName("toolbox-list");
    var i;
    for (i = 0; i < x.length; i++) {
        x[i].style.backgroundColor = "pink";
    }
})();
// document.getElementById('nav-searchform').style.visibility='hidden';