beautify baidu

make baidu beautiful

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         beautify baidu
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  make baidu beautiful
// @author       lgx
// @match        https://www.baidu.com/s*
// @match        https://www.baidu.com/baidu*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=baidu.com
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    document.getElementById('con-right-bottom')?.remove()
    const rcht = 'right-ceiling-has-tag'
    for (let sheet of document.styleSheets) {
        try {
            const rule = [...sheet.rules].find(rule => rule.selectorText?.includes(`.${rcht}`))
            if (rule) {
                rule.style.top = '148px'
            }
        } catch {}
    }
    if (document.querySelector('#searchTag')) {
        try {
            let r=$.prototype.removeClass,a=$.prototype.addClass,ww=document.getElementById('wrapper_wrapper'),cw=document.getElementById('con-ceiling-wrapper')
            $.prototype.addClass=function(cls){cls!==rcht&&a.call(this,cls);if(cls==='tag-fixed'){ww.style.marginTop='49px'}}
            $.prototype.removeClass=function(cls){cls!==rcht&&r.call(this,cls);if(cls==='tag-fixed')ww.style.marginTop=''}
            window.addEventListener('scroll',e=>cw.classList[cw.previousElementSibling.getBoundingClientRect().bottom<=128?'add':'remove'](rcht))
        } catch {}
    }
})();