// ==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/*
// @downloadURL none
// ==/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(`
`);
// 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 = $(`
//
//
//
// 渲染
//
//
// `)[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() { // 遍历所有 元素
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() { // 遍历所有 元素
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'})
}
*/