SeaTable自定义样式(在线版)

SeaTable自定义样式

目前为 2023-09-04 提交的版本。查看 最新版本

// ==UserScript==

// @name         SeaTable Custom Style (OnLine)
// @name:zh-CN   SeaTable自定义样式(在线版)

// @description  Custom SeaTable Style
// @description:zh-cn SeaTable自定义样式

// @namespace    http://tampermonkey.net/
// @version      0.6
// @author       oraant
// @grant        none
// @license      MIT

// @require      http://code.jquery.com/jquery-3.4.1.min.js
// @match        *://*:4480*
// @match        *://*.192.168.1.2:4480/*
// @match        *://*.seatable.cn/*
// @match        *://*.table.everything.pub/*
// @match        *://*.biz.oraant.cc/*

// ==/UserScript==



/*--- waitForKeyElements():  A utility function, for Greasemonkey scripts, that detects and handles AJAXed content. */

function waitForKeyElements ( /* IMPORTANT: This function requires your script to have loaded jQuery. */
    selectorTxt,    /* Required: The jQuery selector string that specifies the desired element(s). */
    actionFunction, /* Required: The code to run when elements are found. It is passed a jNode to the matched element. */
    bWaitOnce,      /* Optional: If false, will continue to scan for new elements even after the first match is found. */
    iframeSelector  /* Optional: If set, identifies the iframe to search. */
) {
    var targetNodes, btargetsFound;

    if (typeof iframeSelector == "undefined")
        targetNodes     = $(selectorTxt);
    else
        targetNodes     = $(iframeSelector).contents().find(selectorTxt);

    if (targetNodes  &&  targetNodes.length > 0) {
        btargetsFound   = true;
        /*--- Found target node(s).  Go through each and act if they are new. */
        targetNodes.each ( function () {
            var jThis        = $(this);
            var alreadyFound = jThis.data ('alreadyFound')  ||  false;

            if (!alreadyFound) {
                //--- Call the payload function.
                var cancelFound     = actionFunction (jThis);
                if (cancelFound)
                    btargetsFound   = false;
                else
                    jThis.data ('alreadyFound', true);
            }
        } );
    }
    else {
        btargetsFound   = false;
    }

    //--- Get the timer-control variable for this selector.
    var controlObj      = waitForKeyElements.controlObj  ||  {};
    var controlKey      = selectorTxt.replace (/[^\w]/g, "_");
    var timeControl     = controlObj [controlKey];

    //--- Now set or clear the timer as appropriate.
    if (btargetsFound  &&  bWaitOnce  &&  timeControl) {
        //--- The only condition where we need to clear the timer.
        clearInterval (timeControl);
        delete controlObj [controlKey]
    }
    else {
        //--- Set a timer, if needed.
        if ( ! timeControl) {
            timeControl = setInterval ( function () {
                    waitForKeyElements ( selectorTxt, actionFunction, bWaitOnce, iframeSelector );
                },
                300
            );
            controlObj [controlKey] = timeControl;
        }
    }
    waitForKeyElements.controlObj   = controlObj;
}





$("head").append(`
    <style type="text/css" id="custom_tags_css">
        /* 整体风格

        body { font-family:"Microsoft YaHei Light" } */

        /* 为自律的奖罚标签设置特殊的颜色背景 */
        div.react-grid-Cell[data-column_key="Je1Q"] .link { background-color:#39ab69; color:white; }
        div.react-grid-Cell[data-column_key="l2CX"] .link { background-color:#e36767; color:white; }


        /* 长文本弹窗宽度调整,阅读更加舒适 */
        div.longtext-modal-dialog.longtext-preview  { width:1200px; } /* 预览屏宽度 */
        div.longtext-modal-dialog { width:fit-content; max-width:1800px; } /* 弹窗遮罩宽度 */
        div.longtext-modal-dialog div.editor.article { width:max-content; min-width:800px; } /* 实际内容宽度 */
        div.longtext-modal-dialog div.editor.article div.editor-component { min-height:500px; } /* 鼠标放上去有光标 */
        div.longtext-modal-dialog div.editor.article table { width: inherit; } /* 去掉表格横线 */
        div.longtext-modal-dialog div.editor.article table tr { display:inherit; } /* 取消表格宽度相等 */
        div.longtext-modal-dialog div.editor.article table td { max-width:400px; } /* 防止某列过宽 */

        /* 长文本弹窗排版样式 */
        div.longtext-modal-dialog h1 { font-size:2.1em; }
        div.longtext-modal-dialog h2 { font-size:1.8em; }
        div.longtext-modal-dialog h3 { font-size:1.5em; }
        div.longtext-modal-dialog h4 { font-size:1.2em; }
        div.longtext-modal-dialog h5 { font-size:0.9em; }
        div.longtext-modal-dialog h6 { font-size:0.7em; }

        /* 公式默认编辑框大小 */
        .edit-formula-popover .popover { width:900px; max-width:900px; max-height:calc(100% - 50px); height:calc(100% - 50px); }
        .formula-editor .CodeMirror { height:480px!important; }
        .formula-container .formula-content { height:inherit; }
        .formula-tips .formula-column-func { flex:auto; }
        .formula-tips .formula-example-container { flex:auto; }

        /* 调整列标题的tooltip格式 */  /* 改为动态调整,可以防止tip位置偏离太远 */
        /* div.tooltip-inner.column-description-tip { white-space: pre; width:fit-content; max-width:800px; height:fit-content; max-height:800px; } */
        /* div.longtext-modal-dialog table td span { white-space: pre; } */

        /* ---------------------------------------------------------------------------------------------------- */

        /* 子表标签竖向排列,更加紧致,放的更多
        div.tables-tabs-container div.tables-tabs-content { margin-left:0px; }
        div.tables-tabs-content div.tables-tabs { padding-right:0px; }
        div.tables-tabs-content li.tabs-tab { margin-right:0px; }
        div.tables-tabs-content div.tab-link { height:50px; padding:0px 0px 0px 0px!important; writing-mode:tb-rl; line-height:24px; }
        div.tables-tabs-content span.tab-title { font-size:14px }
        #header { height:30px; }
        #header .title { height:inherit; }
        .tables-tabs-container .tables-tabs-operations { width:70px; flex-wrap:wrap; margin-right:0px; }
        .tables-tabs-content .add-table { width:16px; margin-right:0px; }
        .tables-tabs-operations .tables-logs, .tables-tabs-operations .tables-plugins, .tables-tabs-operations .tables-rule, .tables-tabs-operations .tables-share, .tables-tabs-operations .tool-dropdown { margin-right:1px; }
        */

        /* 子表标签横向压缩 */
        #header { height:30px; position:absolute; right:0; padding:0; text:'缩到右上角别占空'; }
        #header .title { height:inherit; }

        #header .logo { margin-left:0; }
        #header .tools { margin-right:0; }
        #header .tool { margin-right:0; }
        .tables-tabs-container { align-items:end; text:'保证右边按钮不被遮住'; }

        #tables { height:100%; }

        .tables-tabs-container .tables-tabs-operations { width:70px; flex:0 0 auto; flex-wrap:wrap; margin-right:0px; text:'保证右边按钮换行折叠'; }
        .tables-tabs-operations .tables-logs, .tables-tabs-operations .tables-plugins, .tables-tabs-operations .tables-rule, .tables-tabs-operations .tables-share, .tables-tabs-operations .tool-dropdown { margin-right:1px; text:'保证右边按钮紧密堆叠'; }

        .tables-tabs-container .tables-tabs-content { flex-grow:1; margin-left:0; min-height:75px; align-items:end; text:'保证左边标签可以扩展顶到右侧按钮'; }
        .tables-tabs-content .add-table { margin-right:0px; text:'去掉添加按钮的留白'; }

        .tables-tabs-content .tables-nav-tabs { flex-wrap:wrap; width:100%; text:'开启换行,限制宽度,保证可以正常换行'; }
        .tables-tabs-content .tabs-tab { flex-grow:0; margin-right:0; text:'不扩充才能正常左对齐'; }
        .tables-tabs-content .tab-link { padding:0 5px; border-radius:0; }
        .tables-tabs-content .tabs-tab.tabs-tab-active .tab-link { padding:0 5px !important; }
        div.tables-tabs-content span.tab-title { font-size:13px }
        div.tables-tabs-content span.tab-dropdown { left:0px; right:inherit; }
        .tabs-tab .tab-title .dtable-icon-description { margin-left:-12px!important; opacity:0; }
        .tabs-tab .tab-title .dtable-icon-description:hover { opacity:1; }
        @media (min-width: 767.8px) { .logo { flex-basis: 0; flex-shrink: 1; } }

        /* 取消单元格边框,或者调浅 */
        div.react-grid-Cell{ border:none !important; }
        /* div.react-grid-Cell{ border-right:1px solid #f9f9f9;border-bottom: 1px solid #f9f9f9; } */

        /* 单元格默认不压缩空格 */
        /* div.grid-cell-type-default {white-space: pre;} /* font-family: Agave, "Ubuntu Mono", Inconsolata */
    </style>
`);


// waitForKeyElements ("div.grid-cell-type-default", ttt);
// function ttt(){
//     console.log('111')
// }


// waitForKeyElements ("div#dtable-row-height-popover", add_custom_btns);
// function add_custom_btns(){ // 渲染表格内的元素
//     let btn = $(`
//         <div class="toolbar-item ml-2 view-row-render" id="dtable-row-render-popover">
//             <span class="toolbar-btn view-row-render">
//                 <i class="dtable-font dtable-icon-sync"></i>
//                 <span>渲染</span>
//             </span>
//         </div>
//     `)[0];
//     btn.addEventListener("click", function() {
//         $('.grid-cell-type-default').each(function() {
//             $(this).html($(this).text());
//         });
//     });
//     $('div#dtable-row-height-popover').after(btn);
// }



waitForKeyElements ("div.tooltip-inner", tip_return); // .column-description-tip
function tip_return(){ // 使列描述中内容支持换行符号
    $('div.tooltip-inner').each(function() { // 遍历所有 <div> 元素
        var text = $(this).text(); // 获取当前元素中的文本内容
        if(text.includes('■')) { // 如果文本内容包含 '■'
            var newText = text.replace(/■/g, '\n'); // 将所有 '■' 替换为换行符
            $(this).text(newText); // 更新元素的文本内容
            console.log('replace tip !!!')
        }
    });

    $('div.tooltip-inner').css({'white-space':'pre', 'width':'fit-content', 'max-width':'800px', 'height':'fit-content', 'max-height':'800px'})
}



waitForKeyElements ("div.longtext-modal-dialog table span", span_return);
function span_return(){ // 使长文本中的表格支持换行符号

    console.log('span !!!')

    $('div.longtext-modal-dialog table span[data-slate-string="true"]').each(function() { // 遍历所有 <span> 元素
        var text = $(this).text(); // 获取当前元素中的文本内容
        if(text.includes('■')) { // 如果文本内容包含 '■'
            var newText = text.replace(/■/g, '\n'); // 将所有 '■' 替换为换行符
            $(this).text(newText); // 更新元素的文本内容
            console.log('replace span !!!')
        }
    });
}



waitForKeyElements (".tab-link", tab_link_style);
function tab_link_style(){ // 记得大的数放在前面,防止小数在前时,-5删掉无法识别-50的bug

    console.log('tab link style !!!')

    // 子表标签透明空格,逻辑更加清晰 // 记得大的数放在前面,防止小数在前时,-5删掉无法识别-50的bug

    $('.tab-link:contains("-200")').css({'opacity': 0.3, 'padding':0, 'border-radius':0, 'width':'200px'})
    $('.tab-title:contains("-200")').text('​')

    $('.tab-link:contains("-100")').css({'opacity': 0.3, 'padding':0, 'border-radius':0, 'width':'100px'})
    $('.tab-title:contains("-100")').text('​')

    $('.tab-link:contains("-50")').css({'opacity': 0.3, 'padding':0, 'border-radius':0, 'width':'50px'})
    $('.tab-title:contains("-50")').text('​')

    $('.tab-link:contains("-30")').css({'opacity': 0.3, 'padding':0, 'border-radius':0, 'width':'30px'})
    $('.tab-title:contains("-30")').text('​')

    $('.tab-link:contains("-20")').css({'opacity': 0.3, 'padding':0, 'border-radius':0, 'width':'20px'})
    $('.tab-title:contains("-20")').text('​')

    $('.tab-link:contains("-10")').css({'opacity': 0.3, 'padding':0, 'border-radius':0, 'width':'10px'})
    $('.tab-title:contains("-10")').text('​')

    $('.tab-link:contains("-5")').css({'opacity': 0.3, 'padding':0, 'border-radius':0, 'width':'20px'})
    $('.tab-title:contains("-5")').text('​')

    $('.tab-link:contains("--")').css({'opacity': 0.3, 'padding':'2px 1px !important', 'border-radius':0, 'width':'3px'})
    $('.tab-title:contains("--")').text('​')

    // 子表标签白色竖线,逻辑更加清晰

    $('.tab-link:contains("|||")').css({'padding':0.3, 'margin':'0 5px', 'border-radius':0, 'width':'5px', 'background-color':'white'})
    $('.tab-title:contains("|||")').text('​')

    $('.tab-link:contains("||")').css({'padding':0.3, 'margin':'0 2px', 'border-radius':0, 'width':'3px', 'background-color':'white'})
    $('.tab-title:contains("||")').text('​')

    // 子表标签换行,多行展示逻辑清晰

    $('.tabs-tab:contains("-n")').css({'flex-basis': '100%', 'height':'3px', 'width':'20px', 'overflow':'hidden', 'opacity':0.3})
    $('.tab-title:contains("-n")').text('​')
}


/* waitForKeyElements (".react-grid-Cell", grid_cell_style);
function grid_cell_style(){

    console.log('grid cell style !!!')

     // 为单元格增加边框线

    $('.react-grid-Cell:contains("世界")').css({'border-left':'solid 2px black;'})

    // 人工竖直分割线

    // $('.react-grid-HeaderCell:contains("---")').css({'border-bottom':0, 'background-color':'white'})
    // $('.react-grid-HeaderCell:contains("---") > *').css({'opacity': 0})

    // $('.react-grid-Cell:contains("---")').css({'border-bottom':0})
    // $('.react-grid-Cell:contains("---") > *').css({'opacity': '0'})

}
*/

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址