清爽百度

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

当前为 2021-06-08 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         清爽百度
// @version      0.5.2
// @description  这是一个登录净化百度首页的脚本,个人使用
// @author       想吃糖
// @match        https://www.baidu.com/
// @grant        none
// @namespace https://greasyfork.org/users/597361
// ==/UserScript==
(async 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`;
    let sid = $.cookie.get("H_PS_PSSID");
    //初始化请求百度配置
    $.ajax({
        url: "https://www.baidu.com/home/page/data/settinghome",
        type: "GET",
        data:{sid:sid},
        dataType: "jsonp", //指定服务器返回的数据类型
        success: function (data) {
            $.localstorage.set("IsNewPage",data.bsData.settingelem[1].tipsvalue);
        }
    });
    class InitSetting{
        constructor(options){
            this.data = options.data;
            console.log(options)
            //初始化 净化设置
            this.createSetting();
            //初始化 一言
            this.createhitokoto()
        }
        createSetting(){
            console.log(this)
            let SettingDiv = document.createElement("div");
            SettingDiv.innerText = "净化设置";
            SettingDiv.className = "s-top-right-text c-font-normal c-color-t";
            $("#u1>.s-weather-wrapper").before(SettingDiv);
            console.log("初始化InitSetting")
        }
        createhitokoto(){
            //一言模块
            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);
            });
        }
    }
    new InitSetting({
        data :{
                a:"123"
        }
    });
    //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)



    //输入框清空事件
    //$('.self-btn').click(()=>{ setTimeout(function(){ $('.s_ipt').val('');  $('.hitokoto').hide() },150) });
    $("#kw").bind("input propertychange",function(e){
        MasterFun();
    });
    //下拉框 去掉不协调白色
    var SelUlInval;
    $("#kw").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)
        },50)
    })
    // 精简部分
    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-new>ul").css({"border":"none"});
        if($.localstorage.get("IsNewPage").value == "on")return;
        $(".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"});
        //输入后 输入框变成默认颜色
        $('#kw').css({"background":"transparent"});
        //下拉变回默认颜色
        if($('div.bdsug.bdsug-new.bdsugbg')[0]){
            $('div.bdsug.bdsug-new.bdsugbg').css({"background":"white"});
        }
    }
})();