Tasmota textarea maximizer

Maximizes the textarea's on the console and scripting screens. Makes editing a little easier. Also added js to save the script with ajax rather than submitting the page. ctrl + s will save the script

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Tasmota textarea maximizer
// @namespace    http://monkeyr.com/
// @license      MIT
// @version      2.2
// @description  Maximizes the textarea's on the console and scripting screens. Makes editing a little easier. Also added js to save the script with ajax rather than submitting the page. ctrl + s will save the script
// @author       mh
// @match        http://*/s10*
// @match        http://*/cs*
// @match        http://*/ufse*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tasmota.github.io
// @require      http://code.jquery.com/jquery-latest.min.js
// @grant        GM_notification
// ==/UserScript==

(function($) {
    // resize
    const cont = $('body>div').css({'min-width': '98%'});
    //console.log(cont.children())
    let textarea=null, others_height=0, delta_height=200;
    cont.children().each((i,e) => {
        const ele = $(e);
        //console.log(e);
        if(ele.is('fieldset')){
            textarea=ele.find('textarea');
        }
        else if(ele.is('textarea')){
            delta_height=100;
            textarea=ele;
        }
        else{
            others_height+=ele.outerHeight();
            //console.log(ele.outerHeight());
        }
    });
    textarea.height(document.documentElement.clientHeight - others_height - delta_height);
    window.addEventListener('resize', function() {textarea.height(document.documentElement.clientHeight - others_height - delta_height);console.log('resize event')});

    // Save script windows in-place
    const save = function(e){
        e.preventDefault();
        const btn = $(this),
              frm = btn.closest('form'),
              formData = new FormData(frm[0]);

        formData.append(btn.attr('name'), '');
        //console.log(formData)

        $.ajax({
            type: "POST",
            url: btn.attr('formaction'),
            data: formData,
            cache: false,
            processData: false,
            contentType: false,
            success: function(data){
                GM_notification ( {text: 'Saved', timeout: 3000} );
            },
            error: function(data){
                GM_notification ( {text: 'Save failed!'} );
            }
        });
    },
    button = $('button[name="save"]').on('click', save);
    document.addEventListener('keydown', function(e) {
        if (e.keyCode==83 && e.ctrlKey) {
            e.cancelBubble = true;
            e.preventDefault();
            e.stopImmediatePropagation();
            $(button).click();
        }
        return false;
    }, true);
})(jQuery);