修復 Microsoft To Do 欄位高度讓 textarea 高度自動符合內容
// ==UserScript==
// @name Microsoft To Do 自動調整欄位高度
// @namespace http://tampermonkey.net/
// @version 1.0.2
// @description 修復 Microsoft To Do 欄位高度讓 textarea 高度自動符合內容
// @author shanlan
// @match https://to-do.office.com/tasks/*
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
// 取得所有目標 textarea
function autoResizeAll() {
document.querySelectorAll('textarea.ms-TextField-field').forEach(function(textarea) {
textarea.rows = 1; // 確保預設只有一行
// 自動調整高度
textarea.style.height = 'auto';
textarea.style.height = textarea.scrollHeight + 'px';
// 綁定 input 事件
textarea.addEventListener('input', function() {
this.style.height = 'auto';
this.style.height = this.scrollHeight + 'px';
});
});
}
// 頁面載入時執行
window.addEventListener('load', autoResizeAll);
// 如果有 SPA 或動態載入,可以定時檢查
setInterval(autoResizeAll, 300);
})();