Baidu Masonry

change Baidu search result page into masonry layout

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

// ==UserScript==
// @name         Baidu Masonry
// @namespace    ChocoY
// @version      0.2
// @description  change Baidu search result page into masonry layout
// @author       ChocoY
// @match        https://www.baidu.com/s*
// @icon         https://www.google.com/s2/favicons?domain=baidu.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let content = document.querySelector('#content_left')

    let left = 40,right = 40

    function masonry(){
        function placeItem(n){
            if(n.nodeName != 'DIV'){
                return
            }

            n.style.width='calc(50vw - 100px)'
            n.style.visibility="visible"

            if(left <= right){
                n.style.left = '30px'
                n.style.top=left + 'px'
                left += n.offsetHeight + 10
                content.style.height = left+'px'
            } else {
                n.style.left='calc(50% + 15px)'
                n.style.top = right + 'px'
                right +=n.offsetHeight + 10
                content.style.height = right + 'px'
            }
        }


        left= 40
        right = 40
        for(let i =0;i <content.children.length;i++){
            placeItem(content.children.item(i))
        }
    }
    masonry()
    content.onchange=masonry

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址