【油猴】调整论坛聊天室高度

最近由于经常使用聊天室,感觉默认的聊天室打开之后高度太低了,因此简单用个油猴脚本把高度调高一点,同时聊天室的右边距缩窄避免遮挡左侧看帖子时间线。

// ==UserScript==
// @name         调整 Linux.do 聊天室的高度
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Adjust the style of chat drawer components on linux.do
// @author       马克思
// @match        *://linux.do/*
// @grant        none
// @run-at       document-end
// @icon         https://www.google.com/s2/favicons?sz=64&domain=linux.do
// ==/UserScript==

(function() {
    'use strict';
    function adjustChatDrawerStyle() {
        const chatDrawerOutletContainer = document.querySelector('.chat-drawer-outlet-container');
        if (chatDrawerOutletContainer) {
            chatDrawerOutletContainer.style.setProperty('--composer-right', '0px');
        }

        const chatDrawer = document.querySelector('.chat-drawer.is-expanded');
        if (chatDrawer) {
            const viewportHeight = window.innerHeight;
            const newHeight = viewportHeight * 0.85 + 'px'; // 调整到页面高度的85%
            const newWidth = 360 + 'px'; // 宽度从原来的400px调整到360px
            chatDrawer.style.height = newHeight;
            chatDrawer.style.width = newWidth;
        }
    }

    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            if (mutation.addedNodes.length) {
                adjustChatDrawerStyle();
            }
        });
    });

    const config = { childList: true, subtree: true };
    observer.observe(document.body, config);
    adjustChatDrawerStyle();
})();

7 个赞

油猴·马克思

1 个赞


我这样可以吗

1 个赞

nonono 放在角落摸鱼才不会显眼

1 个赞

有没有一种可能,其实是可以拖拉的

1 个赞

哈哈哈哈 发现了,左上角可以手动拖拉。。。

坏了,之前没发现可以拖拽,我的失误。麻烦版主把我帖子关了吧

你可以做一下美化吗?然后把自己放到右边这种

可以优化一下界面啥的

这种需求不是应该用 Stylus 吗

哈哈哈,佬友太幽默了

搞七捻三软件开发

油猴·马克思

1 个赞