Greasy Fork is available in English.

Greasy Fork editor adjuster

Automatically adjusts the height of editor.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Greasy Fork editor adjuster
// @namespace    https://greasyfork.org/ja/users/570127
// @version      2025.12.14.5
// @description  Automatically adjusts the height of editor.
// @description:ja ソースエディタのテキストエリアの高さを行数に応じて高くします。
// @author       universato
// @match        https://greasyfork.org/*
// @license      MIT
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const textarea = document.querySelector('#script_version_code');
    if (!textarea) return;

    // Adjust the height of editor.
    const numberOfLines = textarea.value.split('\n').length;
    textarea.style.height = (18 * Math.min(44, Math.max(12, numberOfLines))) + "px";

    const submit = document.querySelector('input[type="submit"][name="commit"]');
    if (!submit) return;

    return;

    submit.addEventListener('click', function (event) {
        const hasTrailingSpace = /[ \t]+$/m.test(textarea.value);
        if (!hasTrailingSpace) return;

        const proceed = confirm(
            '[UserScript] Greasy Fork editor adjuster:\n\n' +
            'Trailing whitespace were found.\n\n' +
            'Do you want to continue and submit anyway?'
        );

        if (!proceed) {
            event.preventDefault();
            event.stopPropagation();
        }
        // proceed === true の場合は何もせず送信続行
    }, true); // capture
})();