清爽百度

这是一个登录净化百度首页的脚本,个人使用

目前為 2021-06-06 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         清爽百度
// @version      0.3
// @description  这是一个登录净化百度首页的脚本,个人使用
// @author       想吃糖
// @match        https://www.baidu.com/
// @grant        none
// @namespace https://greasyfork.org/users/597361
// ==/UserScript==
(function() {
    'use strict';
    if((window.location.href).split("/")[2] != "www.baidu.com") return false;
    var IsLogin = $('.s-top-login-btn').text() == '登录' ? "#lg" : "#s_fm";
    var ClearVal = `#s_lg_img,.s-hotsearch-title,#hotsearch-content-wrapper,#s-top-left,#bottom_layer,#s_side_wrapper,#s_top_wrap`;
    //body设置
    //document.body.style.fontFamily = 'Quicksand,"游ゴシック","Yu Gothic","游ゴシック体",YuGothic,"Yu Gothic UI","ヒラギノ角ゴ Pro W3","Hiragino Kaku Gothic Pro","Meiryo UI","メイリオ",Meiryo,sans-serif';
    //document.body.style.background = 'url(https://api.ixiaowai.cn/mcapi/mcapi.php) no-repeat';
    // if (window.location.href.length > 25) {
    //     $(".wrapper_new #head").css({
    //         "background": "transparent"
    //     });
    //     setTimeout(()=>{
    //         $(".bgcImg").css({
    // position: fixed;
    // top: 0;
    // left: 0;
    // height: 100%;
    // width: 100%;
    // min-width: 1000px;
    // z-index: -10;
    // background-position: center 0;
    // background-repeat: no-repeat;
    // background-size: cover;
    // -webkit-background-size: cover;
    // -o-background-size: cover;
    // zoom: 1;
    //         });
    //         $('.s_ipt').css({
    //             'border': 'none'
    //         });
    //     },1000)
    // }
    // 全局背景
    // var img = document.createElement('img');
    //img.src = 'https://api.dongmanxingkong.com/suijitupian/acg/1080p/index.php';
    // $(img).css({
    //     "position": "fixed",
    //     "top": "0",
    //     "left": "0",
    //     'z-index':'-1',
    //     "width":"100%",
    //     "height":"100%"
    // }).attr("class", "bgcImg")
    // $('body').prepend(img)

    //一言模块
    fetch('https://v1.hitokoto.cn/?c=a')
        .then(function (response) {
        return response.json();
    }) .then(function (myJson) {
        var myText = document.createElement('div');
        myText.className = 'hitokoto';
        $(myText).css({
            'position': 'absolute',
            'left': '50%',
            'top': '50%',
            'width': '200%',
            'transform': 'translate(-50%,-50%)',
            'textOverflow': 'ellipsis',
            'whiteSpace': 'normal',
            'textAlign': 'center',
            'fontSize': '1.6rem',
            'color': 'black'
        })
        myText.innerText = myJson.hitokoto;
        //一言的作者 处理
        var fromWho = '';
        if (myJson.from_who == null)fromWho = '';
        //时间处理
        var CreateTime = new Date(parseFloat(myJson.created_at + '000'));
        var CreatTime = CreateTime.toLocaleDateString() + CreateTime.toLocaleTimeString();
        myText.innerHTML += '<span id="spanText" style="font-size:1rem;">' + '<br>' + '来自—' + myJson.from + '   ' + fromWho + '   ' + CreatTime + '</span>';
        $(IsLogin).append(myText);
    });

    //输入框清空事件
    //$('.self-btn').click(()=>{ setTimeout(function(){ $('.s_ipt').val('');  $('.hitokoto').hide() },150) });
    $(".s_ipt").bind("input propertychange",function(e){
        MasterFun();
    });
    //下拉框 去掉不协调白色
    var SelUlInval;
    $(".s_ipt").bind("focus",()=>{
        setTimeout(()=>{
            SelUlInval = setInterval(()=>{
                if($('div.bdsug.bdsug-new.bdsugbg>ul')[0]){
                    $('div.bdsug.bdsug-new.bdsugbg>ul').css({"border":"none"});
                    clearInterval(SelUlInval);
                }
            },200)
        },300)
    })

    //搜索框颜色
    $('.s_ipt').css({
        'border': '#4e6ef2 solid 2px'
    })
    // 精简部分
    var BaiduImgSIn = setInterval(()=>{
        if($('#s_lg_img')[0]){
            $(ClearVal).hide();
            //输入框
            $('#kw').css({
                "background":"#0000002e"
            })
            //上传小相机背景
            $("span#s_kw_wrap>span:first-child").css({
                "background":"url(https://dss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/searchbox/nicon-10750f3f7d.png) no-repeat",
                "background-position-y":"-50px",
            })
            clearInterval(BaiduImgSIn);
        };
    },100);
    //下拉框
    var BaiduSelSIn = setInterval(()=>{
        if($('div.bdsug.bdsug-new.bdsugbg')[0]){
            $('div.bdsug.bdsug-new.bdsugbg').css({"background":"#0000002e"});
            //输入框下拉的
            clearInterval(BaiduSelSIn);
        };
    },100);
    //输入框
    var BaiduInputSIn = setInterval(()=>{
        if($('#kw').val()){
            MasterFun();
            clearInterval(BaiduInputSIn);
        }
    },100);
    function MasterFun(){
        $(".bdsug").css({"background":"rgba(255, 255, 255, 0.77)"});
        $(".hitokoto").hide();
        $(".s_ipt").css({"border":"none"});
        $(".bgcImg").css({"opacity":"0.3","z-index":"-1","width":"100%"});
        $(".wrapper_new #head #page").css({"background":"transparent"});
        $("#page").css({"background":"transparent"});
        $(".bdsug-new>ul").css({"border":"none"});
        //输入后 输入框变成默认颜色
        $('#kw').css({"background":"transparent"});
        //下拉变回默认颜色
        if($('div.bdsug.bdsug-new.bdsugbg')[0]){
            $('div.bdsug.bdsug-new.bdsugbg').css({"background":"white"});
        }
    }
})();