Customize qBittorrent Web UI Font Size

*Customize qBittorrent Web UI Font Size*

目前為 2024-11-16 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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 页面");
    }
})();