Customize qBittorrent Web UI Font Size

*Customize qBittorrent Web UI Font Size*

当前为 2024-11-16 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Customize qBittorrent Web UI Font Size
// @name:zh-cn   修改qBittorrent Web UI字体大小
// @namespace    lanhaha
// @version      0.1
// @description  *Customize qBittorrent Web UI Font Size*
// @description:zh-cn  *修改qBittorrent Web UI字体大小*
// @match        *://*/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // 获取网页的标题
    const pageTitle = document.title;

    // 使用正则表达式匹配包含 "qBittorrent" 和 "Web UI" 的标题
    const titlePattern = /^qBittorrent.*Web UI$/i;

    // 检查页面标题是否匹配正则表达式
    if (titlePattern.test(pageTitle)) {
        console.log("这是 qBittorrent Web UI 页面");

        // 设置默认字体大小
        const fontSize = "14px";  // 可以修改为你希望的字体大小
        const rowHeight = "25px"; // 设置表格行的高度

        // 创建一个新的样式元素
        const style = document.createElement('style');
        style.innerHTML = `
            body {
            font-family: 'FangSong', '仿宋', serif !important;
                font-size: ${fontSize} !important;
            }

            /* 可选:修改其他元素的字体大小 */
            table, th, td , tr{
                font-size: ${fontSize} !important;
            }

                        /* 修改 td 或 th 中的内容的行高,以确保行内内容垂直居中 */
            td, th, tr {
                line-height: ${rowHeight} !important;
            }
        `;

        // 将样式元素添加到页面头部
        document.head.appendChild(style);
    } else {
        console.log("这不是 qBittorrent  Web UI 页面");
    }
})();