Greasy Fork

Greasy Fork is available in English.

绯月布局调整

显示用户名称,压缩楼层,头像屏蔽,首页布局调整

当前为 2021-10-12 提交的版本,查看 最新版本

// ==UserScript==
// @name         绯月布局调整
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  显示用户名称,压缩楼层,头像屏蔽,首页布局调整
// @author       aotmd
// @match        https://bbs.kfmax.com/*
// @grant        none
// ==/UserScript==
let setting={
    压缩楼层:true,
    头像屏蔽:false,
    隐藏背景更改图片:true,
};
(function () {
    addLoadEvent(() => {
        window.setTimeout(() => {
            let elementNodeListOf = document.querySelectorAll(".indexlbtc > a");
            for (let i = 0; i < elementNodeListOf.length; i++) {
                let uname=elementNodeListOf[i].getAttribute("uname");
                let spanElement = document.createElement('span');
                spanElement.innerText=uname;
                spanElement.className="indexlbtc_u";
                elementNodeListOf[i].appendChild(spanElement);
            }
        }, 0);
    });

    addStyle(`
        span.indexlbtc_u {
            display: inline-block;
            float: left;
            width: 40px;
            text-align: center;
            overflow: visible;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
        span.indexlbtc_s {
            width: 60px!important;
        }
        span.indexlbtc_t {
            width: 480px!important;
        }
    `);
    addStyle(`
        /*布局打回原形*/
        .indexlbtc a {
            letter-spacing: unset!important;
            line-height: unset!important;
            height: unset!important;
            display: unset!important;
        }
        .rightboxa {
            line-height: normal!important;
            border: initial!important;
        }
        a.k_butt.k_blk {
            border: unset!important;
        }
    `);
    if (setting.压缩楼层){
        addStyle(`
            /*楼层压缩*/
            div[style*="min-height:280px"] {
                min-height: auto!important;
            }
            .readidms {
                height: auto;
            }
            /*缩短头像高度*/
            .readidmstop {
                height: auto;
                line-height: initial;
            }
        `);
    }
    if (setting.头像屏蔽){
        addStyle(`
            /*头像屏蔽*/
            /*.readidmstop {
                display: none;
            }*/
        `)
    }
    if (setting.隐藏背景更改图片){
        addStyle(`
            /*背景修改图片隐藏*/
            a.rightbox2 {
                display: none;
            }
        `);
    }
    /**
     * 添加浏览器执行事件
     * @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));
    }
})();