百度界面优化

百度的界面优化

当前为 2020-04-05 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name                   百度界面优化
// @namespace              http://tampermonkey.net/
// @version                1.0.0.1
// @description            百度的界面优化
// @author                 YiJie
// @create                 2020-04-05
// @match                  https://www.baidu.com/
// @require                https://code.jquery.com/jquery-1.10.2.min.js
// @grant                  GM_setValue
// @grant                  GM_getValue
// @grant                  GM_deleteValue
// ==/UserScript==
(function() {
    'use strict';
    GM.setValue = GM_setValue;
    GM.getValue = GM_getValue;
    console.clear();
    console.log("百度界面优化");

    function cssToObj(css) {
        var regex = /([\w-]*)\s*:\s*([^;]*)/g;
        var match, properties={};
        while(match=regex.exec(css)) properties[match[1]] = match[2].trim();
        return properties;
    }
    function setBackgroundImg(sel){
        var imgSrcList = [
            "https://i.ibb.co/s3JKYMF/000.jpg",
            "https://i.ibb.co/tsb7Cfn/001.jpg",
            "https://i.ibb.co/6sBQw9q/002.jpg",
            "https://i.ibb.co/MP4G8j2/003.jpg",
            "https://i.ibb.co/FWwkmy2/004.jpg",
            "https://i.ibb.co/94SM1Sy/005.jpg",
            "https://i.ibb.co/nQddnNb/006.jpg",
            "https://i.ibb.co/TkF20QS/007.jpg",
            "https://i.ibb.co/hs9z9PJ/008.jpg",
            "https://i.ibb.co/p3tTNpQ/009.jpg",
            "https://i.ibb.co/GM5BvmT/010.jpg",
            "https://i.ibb.co/3mz84QJ/011.jpg",
            "https://i.ibb.co/gjhYqrL/012.jpg",
            "https://i.ibb.co/bvJLyY7/013.jpg",
            "https://i.ibb.co/z8nc4j7/014.jpg",
            "https://i.ibb.co/zJLbp2s/015.jpg",
            "https://i.ibb.co/9GwtCsp/016.jpg",
            "https://i.ibb.co/hs8Xthb/017.jpg",
            "https://i.ibb.co/pKycnJM/018.jpg",
            "https://i.ibb.co/BzbRLRy/4.jpg",
            "https://i.ibb.co/BrktnNc/20190804-163142529-i-OS.jpg",
            "https://i.ibb.co/4Fw8XRs/20190805-010826105-i-OS.jpg",
            "https://i.ibb.co/XDvW1Cd/20190805-010841479-i-OS.jpg",
            "https://i.ibb.co/kBySyBb/20190805-010852315-i-OS.jpg",
            "https://i.ibb.co/7Rw98XB/20190805-010909179-i-OS.jpg",
            "https://i.ibb.co/sP6QZ2t/20191001-075308938-i-OS.jpg",
            "https://i.ibb.co/Lx0BMCP/20191001-075336361-i-OS.jpg",
            "https://i.ibb.co/K6qkSsV/20191001-075342746-i-OS.jpg",
            "https://i.ibb.co/dK6Tmmc/20191001-075348921-i-OS.jpg",
            "https://i.ibb.co/KG9cNm3/20191001-075353062-i-OS.jpg",
            "https://i.ibb.co/TRL1ZHg/20191001-075416392-i-OS.jpg",
            "https://i.ibb.co/b1S1fks/20191001-075427752-i-OS.jpg",
            "https://i.ibb.co/3MnwMth/20191001-075432952-i-OS.jpg",
            "https://i.ibb.co/zJCsBHP/20191001-075438207-i-OS.jpg",
            "https://i.ibb.co/gDm6Fmg/20191001-075445325-i-OS.jpg",
            "https://i.ibb.co/4NL9hFM/20191001-075449837-i-OS.jpg",
            "https://i.ibb.co/dMRVSZd/20191001-075454275-i-OS.jpg",
            "https://i.ibb.co/gzWHrcN/20191001-075458168-i-OS.jpg",
            "https://i.ibb.co/QcmYM8w/20191001-075516346-i-OS.jpg",
            "https://i.ibb.co/bgjBcjJ/20191001-075519978-i-OS.jpg",
            "https://i.ibb.co/yPPtNjL/20191001-075526525-i-OS.jpg",
            "https://i.ibb.co/Rvw8nV4/20191001-075538057-i-OS.jpg",
            "https://i.ibb.co/9g2wKSc/20191001-075604237-i-OS.jpg",
            "https://i.ibb.co/qMhSDQS/20191007-031751146-i-OS.jpg",
            "https://i.ibb.co/wS5BVbM/20191007-032041427-i-OS.jpg",
            "https://i.ibb.co/Sr0fKnp/20191007-032113652-i-OS.jpg",
            "https://i.ibb.co/vL6K108/0.png",
            "https://i.ibb.co/Ht8zfxm/1.jpg",
            "https://i.ibb.co/LSKh5bR/2.png",
            "https://i.ibb.co/JHyVVdB/3.jpg",
            "https://i.ibb.co/Nr0KmNW/4.jpg",
            "https://i.ibb.co/WkCmDcg/5.png",
            "https://i.ibb.co/g63VKV7/6.png",
            "https://i.ibb.co/PMtQPxq/7.png",
            "https://i.ibb.co/PzsCpzs/8.jpg",
            "https://i.ibb.co/CVPTd9J/9.png",
            "https://i.ibb.co/bRvfsmk/10.png",
            "https://i.ibb.co/dGwmykP/11.png",
            "https://i.ibb.co/thrKwq5/12.png",
            "https://i.ibb.co/9GDJbkK/13.jpg",
            "https://i.ibb.co/M1NxHsP/14.jpg",
            "https://i.ibb.co/34n7VqV/15.jpg",
            "https://i.ibb.co/nLWpdrv/16.jpg",
            "https://i.ibb.co/qY6s8c5/17.png",
            "https://i.ibb.co/PFnLqHk/18.png",
            "https://i.ibb.co/rwTft2F/19.jpg",
            "https://i.ibb.co/Pwh0rKJ/20.jpg",
            "https://i.ibb.co/KWDFVDW/21.jpg",
            "https://i.ibb.co/3hBR9Sz/22.png",
            "https://i.ibb.co/fYR4sVb/23.jpg",
            "https://i.ibb.co/Nys5S5x/24.png",
            "https://i.ibb.co/NL7D7hK/25.png",
            "https://i.ibb.co/pR3sHst/26.png",
            "https://i.ibb.co/wS26Y1R/27.jpg",
            "https://i.ibb.co/FYhK1L2/28.png",
            "https://i.ibb.co/Wv39ZCq/29.png",
            "https://i.ibb.co/k1D1T06/30.jpg",
            "https://i.ibb.co/ZKnb0zF/31.png",
        ];
        if(sel==-1) sel = Math.round(Math.random()*imgSrcList.length);
        let img=new Image();
        img.src=imgSrcList[sel];
        img.onload=function(){
            $('#head').css({
                "background-position": "center",
                "background-color": "black",
                "background-size": "100%",
                "background-repeat": "repeat-y",
                "background-image":"url('"+imgSrcList[sel]+"')",
                "transition":"1s",
            });
            setTimeout(function(){
                $('#head').css({
                    "background-color": "white",
                });
            },1000);
        };
        GM.setValue("backImgSelect",sel);
    }
    document.head.appendChild($('<link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">')[0]);
// 删除不必要的部分
    $('#su').css(cssToObj("display: none;"));
    $('div#u1').css(cssToObj("display: none;"));
    $('div#bottom_layer.s-bottom-layer').css(cssToObj("display: none;"));
    $('div#qrcodeCon').css(cssToObj("display: none;"));
// 设置自定义的logo
    $('#lg').html("\
    <div class='title'>\
        <span style='color: rgb(50, 100, 200);'>B</span>\
        <span style='color: rgb(70, 120, 220);'>a</span>\
        <span style='color: rgb(90, 140, 240);'>i</span>\
        <span style='color: rgb(50, 100, 200);'>d</span>\
        <span style='color: rgb(90, 140, 240);'>u</span>\
    </div>").css(cssToObj("background-image: url('');"));
    $('div#lg .title').css(cssToObj("\
        position: relative;\
        top: 200px;\
        width: 100%;height: 100%;\
        color:black;\
        font-size: 80px;\
        font-weight: 600;\
        user-select: none;\
        text-align: center;\
        line-height: 300px;\
    "));
// 搜索框样式
    $('#form .s_ipt_wr').css(cssToObj("\
        position: absolute;\
        top: 200px;;left: calc(50% - 300px);\
        width: 600px;\
        border: 2px solid white;\
        border-radius: 30px;\
        transition: 1s;\
    ")).hover(function(){
        $(this).css(cssToObj("\
            border-radius: 4px;\
            box-shadow: 0 0 20px white;\
        "));
    },function(){
        $(this).css(cssToObj("\
            border-radius: 30px;\
            box-shadow: 0 0 0 white;\
        "));
    });
    $('#form .s_ipt_wr input')
        .css(cssToObj("padding-left: 20px;color: white;"))
        [0].oninput = function(){
// 搜索框下方提示
        $('#fm .bdsug').css(cssToObj("left: 40px;top: 235px;width: 560px;"));
        $('#form .bdsug').css(cssToObj("left: 40px;top: 235px;width: 560px;"));
    };

    var selectNode = $("\
        <div class='selectNode'><i class='fa fa-refresh fa-3x'></i></div>\
    ").css(cssToObj("\
        position: absolute;\
        bottom: 20px;left: 20px;\
        width: 50px;height: 50px;\
        border-radius: 50%;\
        background-image: linear-gradient( 135deg, #3C8CE7 30%, #00EAFF 100%);\
        box-shadow: 0 0 30px white;\
        transition: 1s;\
    ")).hover(function(){
        $(this).css(cssToObj("\
            transform: rotateZ(360deg);\
        "));
    },function(){
        $(this).css(cssToObj("\
            transform: rotateZ(0deg);\
        "));
    }).click(function(){
        setBackgroundImg(-1);
    });
    selectNode.find('i').css(cssToObj("\
        width: 100%;\
        color: rgb(250,250,250);\
        font-size: 25px;\
        text-align: center;\
        line-height: 50px;\
    "));
    document.body.appendChild(selectNode[0]);
    var message = $("\
        <div class='selectNode'><i class='fa fa-comment fa-1x'></i></div>\
    ");
    message.find('i').css(cssToObj("\
        width: 100%;\
        color: rgb(250,250,250);\
        font-size: 100px;\
        text-align: center;\
        line-height: 50px;\
    "));
    document.body.appendChild(message[0]);

    if(typeof(GM.getValue("backImgSelect") == "number")){
        setBackgroundImg(GM.getValue("backImgSelect"));
    }
    else{
        console.log(GM.getValue("backImgSelect"));
        setBackgroundImg(0);
    }
})();