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