Greasy Fork is available in English.

Readable Textarea Expander

Expands small textareas to improve readability and editing comfort on common websites.

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.org/scripts/570704/1780717/Readable%20Textarea%20Expander.js

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Readable Textarea Expander
// @namespace    https://example.com/userscripts
// @version      1.0.0
// @description  Expands small textareas to improve readability and editing comfort on common websites.
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // Minimum height for textareas that are too small
    const MIN_HEIGHT = 220;

    // Apply better sizing to a textarea
    function improveTextarea(textarea) {
        if (!(textarea instanceof HTMLTextAreaElement)) {
            return;
        }

        // Avoid processing the same textarea multiple times
        if (textarea.dataset.expanderApplied === 'true') {
            return;
        }
        textarea.dataset.expanderApplied = 'true';

        const computedStyle = window.getComputedStyle(textarea);
        const currentHeight = parseFloat(computedStyle.height) || textarea.offsetHeight;

        if (currentHeight < MIN_HEIGHT) {
            textarea.style.minHeight = `${MIN_HEIGHT}px`;
        }

        textarea.style.resize = 'vertical';
        textarea.style.lineHeight = '1.5';
        textarea.style.padding = '10px';
        textarea.style.boxSizing = 'border-box';
    }

    // Process all existing textareas
    function processPage() {
        const textareas = document.querySelectorAll('textarea');
        textareas.forEach(improveTextarea);
    }

    // Watch for dynamically added textareas
    const observer = new MutationObserver(() => {
        processPage();
    });

    observer.observe(document.documentElement, {
        childList: true,
        subtree: true
    });

    // Run once on load
    processPage();
})();