Greasy Fork

Greasy Fork is available in English.

b站收藏夹优化

缩小收藏夹列表的间距

当前为 2021-05-30 提交的版本,查看 最新版本

// ==UserScript==
// @name         b站收藏夹优化
// @namespace    http://tampermonkey.net/
// @version      1.0.3
// @description  缩小收藏夹列表的间距
// @author       aotmd
// @match        https://*.bilibili.com/*
// @grant        none
// ==/UserScript==

(function () {
    addLoadEvent(() => {
        window.setTimeout(() => {

        }, 1000);
    });

    addStyle(`
    /*视频页选择收藏夹页面*/
    .collection-m .content .group-list li {
        padding-bottom: 0px!important;
    }

    /*顶栏下拉菜单*/
    .v-dropdown .dropdown-menu li {
        padding: 0px 16px!important;
        text-align: left!important;
    }



    /*我的收藏页面*/
    #page-fav .fav-sidenav .text {
        line-height: normal!important;
    }
    .be-dropdown-trigger {
        height: 20px!important;
    }
    /*弹出菜单位置偏移修复*/
    ul.be-dropdown-menu.menu-align- {
        margin-top: -10px;
    }
    /*收藏夹列表全部显示*/
    #page-fav .fav-sidenav .fav-list-container {
        max-height: none!important;
    }
    /*收藏页面的改变收藏夹列表间距*/
    .wrapper .edit-video-modal .target-favlist .target-favitem {
        height: auto!important;
        margin-bottom: 0px!important;
    }
    /*左右浮动,将两个p标签合并为一行*/
    p.fav-state {
        margin-left: 10px;
        float: right;
    }
    p.fav-name {
        float: left;
    }

    `);

    /**
     * 添加浏览器执行事件
     * @param func 无参匿名函数
     */
    function addLoadEvent(func) {
        let oldOnload = window.onload;
        if (typeof window.onload != 'function') {
            window.onload = func;
        } else {
            window.onload = function () {
                try {
                    oldOnload();
                } catch (e) {
                    console.log(e);
                } finally {
                    func();
                }
            }
        }
    }

    //添加css样式
    function addStyle(rules) {
        let styleElement = document.createElement('style');
        styleElement["type"] = 'text/css';
        document.getElementsByTagName('head')[0].appendChild(styleElement);
        styleElement.appendChild(document.createTextNode(rules));
    }
})();