极简百度首页by: yzl

仅试用于百度首页

目前为 2021-11-08 提交的版本。查看 最新版本

// ==UserScript==
// @name         极简百度首页by: yzl
// @namespace    http://tampermonkey.net/
// @match        https://www.baidu.com/
// @version      0.2
// @description  仅试用于百度首页
// @author       U1iz
// @icon         http://res1433223.net3v.net/img/favicon.png
// @grant        none
// ==/UserScript==

(function() {
    //构建“存在即删除”函数
    function elementRemove(element){
        if(element){
            element.remove();
        };
    };
    //构建“获取元素”函数
    function getElement(name,type,quantity){
        var e;
        if(type == 'c'){
            e = document.getElementsByClassName(name);
            if(quantity){
                for(var i = 0; i < quantity; i++){
                    return(e[i]);
                };
            }
        } else if(type == 'id') {
            e = document.getElementById(name);
        }
            return(e);
    };
    //合集
    function all(){
        //更改全局背景色
        document.body.style.backgroundColor = '#ddd';
        //移除首页下方ad容器
            elementRemove(document.getElementById('s-hotsearch-wrapper'));
            elementRemove(document.getElementById('s-top-left'));
            elementRemove();
            elementRemove();
        //移除首页上方导航栏
            elementRemove(document.getElementById('s_top_wrap'));
        //移除右上用户登录入口
            elementRemove(document.querySelector('.s-top-login-btn'));
        //移除登录界面
            elementRemove(document.getElementById('TANGRAM__PSP_5__'));
            elementRemove(document.getElementsByClassName('pop-mask')[0]);
            elementRemove(document.getElementById('TANGRAM__PSP_4__foreground'));
            elementRemove(document.querySelector('.pass-login-pop-form'));
        //移除右下绝对定位二维码登录
            elementRemove(getElement('s_qrcode_nologin','id'));
        //更改底部bgc 等于页面背景色
        getElement('bottom_layer','id').style.backgroundColor = document.body.style.backgroundColor;
        //禁止点击logo后跳转
        getElement('lg','id').onclick = function(){
            return false;
        };
    };
    all();
    window.onload = function(){
        console.log(getElement('s_ipt', 'c'));

        //设置定时器,每1s执行一次
        setInterval(function(){
            all();
        },1000)
    };
})();