SeaTable自定义样式(在线版)qt

SeaTable自定义样式

  1. // ==UserScript==
  2.  
  3. // @name SeaTable Custom Style (OnLine)
  4. // @name:zh-CN SeaTable自定义样式(在线版)qt
  5.  
  6. // @description Custom SeaTable Style
  7. // @description:zh-cn SeaTable自定义样式
  8.  
  9. // @namespace http://tampermonkey.net/
  10. // @version 1.0
  11. // @author oraant
  12. // @grant none
  13. // @license MIT
  14.  
  15. // @require http://code.jquery.com/jquery-3.4.1.min.js
  16. // @match *://*:4480*
  17. // @match *://*.192.168.1.2:4480/*
  18. // @match *://*.seatable.cn/*
  19. // @match *://*.table.everything.pub/*
  20. // @match *://*.biz.oraant.cc/*
  21. // @match *://*.generate.wiki/*
  22.  
  23. // ==/UserScript==
  24.  
  25.  
  26.  
  27.  
  28.  
  29. // === 基础工具方法 ==================================================================================================================================================================================================
  30.  
  31.  
  32.  
  33.  
  34.  
  35. /*--- waitForKeyElements(): A utility function, for Greasemonkey scripts, that detects and handles AJAXed content. */
  36.  
  37. function waitForKeyElements ( /* IMPORTANT: This function requires your script to have loaded jQuery. */
  38. selectorTxt, /* Required: The jQuery selector string that specifies the desired element(s). */
  39. actionFunction, /* Required: The code to run when elements are found. It is passed a jNode to the matched element. */
  40. bWaitOnce, /* Optional: If false, will continue to scan for new elements even after the first match is found. */
  41. iframeSelector /* Optional: If set, identifies the iframe to search. */
  42. ) {
  43. var targetNodes, btargetsFound;
  44.  
  45. if (typeof iframeSelector == "undefined")
  46. targetNodes = $(selectorTxt);
  47. else
  48. targetNodes = $(iframeSelector).contents().find(selectorTxt);
  49.  
  50. if (targetNodes && targetNodes.length > 0) {
  51. btargetsFound = true;
  52. /*--- Found target node(s). Go through each and act if they are new. */
  53. targetNodes.each ( function () {
  54. var jThis = $(this);
  55. var alreadyFound = jThis.data ('alreadyFound') || false;
  56.  
  57. if (!alreadyFound) {
  58. //--- Call the payload function.
  59. var cancelFound = actionFunction (jThis);
  60. if (cancelFound)
  61. btargetsFound = false;
  62. else
  63. jThis.data ('alreadyFound', true);
  64. }
  65. } );
  66. }
  67. else {
  68. btargetsFound = false;
  69. }
  70.  
  71. //--- Get the timer-control variable for this selector.
  72. var controlObj = waitForKeyElements.controlObj || {};
  73. var controlKey = selectorTxt.replace (/[^\w]/g, "_");
  74. var timeControl = controlObj [controlKey];
  75.  
  76. //--- Now set or clear the timer as appropriate.
  77. if (btargetsFound && bWaitOnce && timeControl) {
  78. //--- The only condition where we need to clear the timer.
  79. clearInterval (timeControl);
  80. delete controlObj [controlKey]
  81. }
  82. else {
  83. //--- Set a timer, if needed.
  84. if ( ! timeControl) {
  85. timeControl = setInterval ( function () {
  86. waitForKeyElements ( selectorTxt, actionFunction, bWaitOnce, iframeSelector );
  87. },
  88. 300
  89. );
  90. controlObj [controlKey] = timeControl;
  91. }
  92. }
  93. waitForKeyElements.controlObj = controlObj;
  94. }
  95.  
  96.  
  97.  
  98.  
  99.  
  100. // === 全局样式修改 ==================================================================================================================================================================================================
  101.  
  102.  
  103.  
  104.  
  105.  
  106. $("head").append(`
  107. <style type="text/css" id="custom_all_css">
  108. /* 整体风格f
  109.  
  110. body { font-family:"Microsoft YaHei Light" } */
  111.  
  112. /* ---------------------------------------------------------------------------------------------------- */
  113.  
  114. /* 为自律的奖罚标签设置特殊的颜色背景 */
  115. div.react-grid-Cell[data-column_key="Je1Q"] .link { background-color:#39ab69; color:white; }
  116. div.react-grid-Cell[data-column_key="l2CX"] .link { background-color:#e36767; color:white; }
  117.  
  118. /* 报错弹窗,宽度缩短。否则阻碍鼠标操作 */
  119. .dtable-toast-manager { max-width:fit-content; }
  120.  
  121. /* 长文本弹窗宽度调整,阅读更加舒适 */
  122. div.longtext-modal-dialog.longtext-preview { width:1200px; } /* 预览屏宽度 */
  123. div.longtext-modal-dialog { width:fit-content; max-width:1800px; } /* 弹窗遮罩宽度 */
  124. div.longtext-modal-dialog div.editor.article { width:max-content; min-width:800px; } /* 实际内容宽度 */
  125. div.longtext-modal-dialog div.editor.article div.editor-component { min-height:500px; } /* 鼠标放上去有光标 */
  126. div.longtext-modal-dialog div.editor.article table { width: inherit; } /* 去掉表格横线 */
  127. div.longtext-modal-dialog div.editor.article table tr { display:inherit; } /* 取消表格宽度相等 */
  128. div.longtext-modal-dialog div.editor.article table td { max-width:400px; } /* 防止某列过宽 */
  129.  
  130. /* 长文本弹窗排版样式 */
  131. div.longtext-modal-dialog h1 { font-size:2.1em; }
  132. div.longtext-modal-dialog h2 { font-size:1.8em; }
  133. div.longtext-modal-dialog h3 { font-size:1.5em; }
  134. div.longtext-modal-dialog h4 { font-size:1.2em; }
  135. div.longtext-modal-dialog h5 { font-size:0.9em; }
  136. div.longtext-modal-dialog h6 { font-size:0.7em; }
  137.  
  138. /* 公式默认编辑框大小 */
  139. .edit-formula-popover .popover { width:900px; max-width:900px; max-height:calc(100% - 50px); height:calc(100% - 50px); }
  140. .formula-editor .CodeMirror { height:480px!important; }
  141. .formula-container .formula-content { height:inherit; }
  142. .formula-tips .formula-column-func { flex:auto; }
  143. .formula-tips .formula-example-container { flex:auto; }
  144.  
  145. /* 调整列标题的tooltip格式 */ /* 改为动态调整,可以防止tip位置偏离太远 */
  146. /* div.tooltip-inner.column-description-tip { white-space: pre; width:fit-content; max-width:800px; height:fit-content; max-height:800px; } */
  147. /* div.longtext-modal-dialog table td span { white-space: pre; } */
  148.  
  149. /* --- 分组相关 ------------------------------------------------------------------------------------------------- */
  150.  
  151. .group-container.group-container-left { z-index:auto!important; } /* 分组时标题过短 */
  152. .group-container.group-container-left .group-header-left.group-header-cell { overflow:visible; }
  153. .group-container.group-container-left .group-title { overflow:visible; }
  154. .group-container.group-container-left .group-cell-value { z-index:1; background-color:#f7f7f7; }
  155. .group-container.group-container-left:hover .group-cell-value { z-index:0; }
  156.  
  157. .summary-item .summary-value { max-width:inherit!important; margin:-5px; }
  158.  
  159. /* ---------------------------------------------------------------------------------------------------- */
  160.  
  161. /* 子表标签横向压缩 */
  162. #header { height:30px; position:absolute; right:0; padding:0; text:'缩到右上角别占空'; }
  163. #header .title { height:inherit; }
  164.  
  165. #header .logo { margin-left:0; }
  166. #header .tools { margin-right:0; }
  167. #header .tool { margin-right:0; }
  168. .tables-tabs-container { align-items:end; text:'保证右边按钮不被遮住'; }
  169.  
  170. #tables { height:100%; }
  171.  
  172. .tables-tabs-container .tables-tabs-operations { width:150px; flex:0 0 auto; flex-wrap:wrap; margin-right:0px; text:'保证右边按钮换行折叠'; }
  173. .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:'保证右边按钮紧密堆叠'; }
  174.  
  175. .tables-tabs-container .tables-tabs-content { flex-grow:1; margin-left:0; min-height:75px; align-items:end; text:'保证左边标签可以扩展顶到右侧按钮'; }
  176. .tables-tabs-content .add-table { margin-right:0px; text:'去掉添加按钮的留白'; }
  177.  
  178. .tables-tabs-content .tables-nav-tabs { flex-wrap:wrap; width:100%; text:'开启换行,限制宽度,保证可以正常换行'; }
  179. .tables-tabs-content .tabs-tab { flex-grow:0; margin-right:0; text:'不扩充才能正常左对齐'; }
  180. .tables-tabs-content .tab-link { padding:0 5px; border-radius:0; }
  181. .tables-tabs-content .tabs-tab.tabs-tab-active .tab-link { padding:0 5px !important; }
  182. /* div.tables-tabs-content span.tab-title { font-size:13px; text:'字体调小塞入更多标签,暂时还没必要'; } */
  183. div.tables-tabs-content span.tab-dropdown { left:0px; right:inherit; }
  184. .tabs-tab .tab-title .dtable-icon-description { margin-left:-12px!important; opacity:0; }
  185. .tabs-tab .tab-title .dtable-icon-description:hover { opacity:1; }
  186. @media (min-width: 767.8px) { .logo { flex-basis: 0; flex-shrink: 1; } }
  187.  
  188. /* --- 压缩列类型或描述 ------------------------------------------------------------------------------------------------- */
  189.  
  190. /* 列类型藏在左边,悬浮时显示 */
  191. .header-cell-container .header-icon { opacity:0; position:absolute; left:0px; top:0px; margin:0; padding:5px 2px; line-height:21px; background-color:rgb(239 239 239); }
  192. .header-cell-container .header-icon:hover { background-color:rgb(230 230 230); } /* 鼠标悬浮在本按钮上时变色 */
  193. .react-grid-HeaderRow:hover .header-icon { opacity:1; } /* 鼠标悬浮在列标题上时显示 */ /* .react-grid-HeaderCell:hover .header-cell-container .header-icon { opacity:1; } */
  194.  
  195. /* 列描述藏在右边,悬浮时显示 */
  196. .column-uneditable-tip { opacity:0; position:absolute; right:0; margin:0!important; padding:5px 2px; line-height:21px; background-color:rgb(239 239 239); }
  197. .column-uneditable-tip:hover { background-color:rgb(230 230 230); } /* 鼠标悬浮在本按钮上时变色 */
  198. .react-grid-HeaderCell:hover .column-uneditable-tip { opacity:1; } /* 鼠标悬浮在列标题上时显示 */
  199.  
  200. /* 下拉菜单直接压扁,使用右键照样可以打开菜单 */
  201. .header-cell-container .dtable-dropdown-menu { position:absolute; right:20px; width:0; padding:0; overflow: hidden; }
  202.  
  203. /* 早期意义不明的代码 */
  204. .header-cell-container .header-cell-left { width:100%; }
  205.  
  206. /* --- 链接卡片收紧 ------------------------------------------------------------------------------------------------- */
  207.  
  208. .link-records-container .row-card-item { height:68px; }
  209. .row-card-item .row-card-item-container .row-card-item-header { top:6px; }
  210. .row-card-item .row-card-item-container .row-card-item-content { height:68px; }
  211.  
  212. /* --- 单元格分割线 ------------------------------------------------------------------------------------------------- */
  213.  
  214. /* 单元格整体背景色改为白色,方便其他单元格显示为底色,假装不存在 */
  215. div#grid-canvas{ background-color:#f5f5f5; }
  216.  
  217. /* 调整单元格边框,或者调浅 */
  218. /* div.react-grid-Cell{ border:none !important; } */
  219. div.react-grid-Cell{ border-right:1px solid #aaa !important; border-bottom:1px solid #aaa !important; }
  220.  
  221. /* 工具条的下划线,改成标题栏的上划线,方便下面的分割列做纯白分割 */
  222. div.table-toolbar{ border-bottom:none; background-color:#f5f5f5; }
  223. div.react-grid-HeaderCell{ background-color:#eee; border-top:1px solid #aaa; border-bottom:1px solid #aaa; border-right:1px solid #aaa; }
  224.  
  225.  
  226. /* 横线分割线 */
  227. .react-grid-Row:has(.grid-cell-type-default[title=ㅤㅤㅤㅤ]) .react-grid-Cell{ border-right:none!important; background-color:#f5f5f5!important; }
  228. .react-grid-Row:has(.grid-cell-type-default[title=ㅤㅤㅤㅤ]) .react-grid-Cell__value{ border-bottom:none!important; }
  229. .react-grid-Row:has(.grid-cell-type-default[title=ㅤㅤㅤㅤ]) .react-grid-Cell-button .react-grid-Cell__value{ display:none; }
  230.  
  231. .react-grid-Row:has(.grid-cell-type-default[title=ㅤㅤㅤㅤㅤㅤ]) .react-grid-Cell{ border-right:none!important; border-bottom:2px black solid!important; background-color:#f5f5f5!important; }
  232. .react-grid-Row:has(.grid-cell-type-default[title=ㅤㅤㅤㅤㅤㅤ]) .react-grid-Cell__value{ border-bottom:none!important; }
  233. .react-grid-Row:has(.grid-cell-type-default[title=ㅤㅤㅤㅤㅤㅤ]) .react-grid-Cell-button .react-grid-Cell__value{ display:none; }
  234.  
  235. .react-grid-Row:has(.grid_cell_type_single-select[title*="​"]) .react-grid-Cell:not(.react-grid-Cell-digital-sign):not(.react-grid-Cell-duration){ border-bottom:1px #eaeaea solid !important; }
  236. .react-grid-Row:has(.grid-cell-type-default[title*="ㅤ◆"]) .react-grid-Cell{ border-bottom:none !important; background-color:#e5f6ff; }
  237. .grid-rows > div:has(.grid-cell-type-default[title*="ㅤ◆"])+div:not(:has(.grid-cell-type-default[title*="ㅤ◆"])) .react-grid-Cell{ border-top:1px solid #aaa; }
  238.  
  239. /* 竖线分割线 */
  240. div.react-grid-HeaderCell:has(i.dtable-icon-handwritten-signature){ color:#f5f5f5; background-color:#f5f5f5; border-bottom:none; border-top:none; }
  241. div.react-grid-Cell-digital-sign{ border-bottom:none!important; border-top:none!important; background-color:#f5f5f5!important; }
  242.  
  243. div.react-grid-HeaderCell:has(i.dtable-icon-duration){ color:#f5f5f5; background-color:#f5f5f5; border-bottom:none; border-top:none; }
  244. div.react-grid-Cell-duration{ border-bottom:none!important; border-top:none!important; background-color:#f5f5f5!important; padding:0; }
  245. div.react-grid-Cell-duration > .react-grid-Cell__value{ height:63%!important; border-bottom:10px solid #e9e9e9; }
  246.  
  247. /* 公式灵活分割 */
  248. div.react-grid-HeaderCell:has(.header-name-text[title*='|']){ color:#f5f5f5; background-color:#f5f5f5; border-bottom:none; border-top:none; }
  249. div.react-grid-Cell-formula:has(.grid-cell-type-default[title*='opacity']) { border-bottom:none!important; border-top:none!important; background-color:#f5f5f5!important; padding:0; }
  250. div.react-grid-Cell-formula:has(.grid-cell-type-default[title*='opacity']) > .react-grid-Cell__value > .grid-cell-type-default { display:none; }
  251.  
  252. div.react-grid-Cell-formula:has(.grid-cell-type-default[title*='===']) > .react-grid-Cell__value{ height:53%!important; border-bottom:3px dashed #55f; }
  253. div.react-grid-Cell-formula:has(.grid-cell-type-default[title*='---']) > .react-grid-Cell__value{ height:53%!important; border-bottom:3px dashed red; }
  254.  
  255.  
  256. /* 单元格默认不压缩空格 */
  257. /* div.grid-cell-type-default {white-space: pre;} /* font-family: Agave, "Ubuntu Mono", Inconsolata */
  258.  
  259. /* --- 单选列较窄时,下拉选项不隐藏 ------------------------------------------------------------------------------------------------- */
  260.  
  261. .multiple-selects-editor-list, .single-selects-editor-list{ min-height:400px; }
  262. .multiple-selects-editor-list .multiple-selects-container, .single-selects-editor-list .single-selects-container{ max-height:400px; }
  263. div.dropdown-menu.single-selects-editor-list.show span.single-select-name { max-width:none !important }
  264.  
  265. </style>
  266. `);
  267.  
  268.  
  269.  
  270.  
  271.  
  272. // === 动态样式修改 ==================================================================================================================================================================================================
  273.  
  274.  
  275.  
  276.  
  277.  
  278. // 使列描述中内容支持换行符号
  279.  
  280. let observer = new MutationObserver(mutations => {
  281. if (document.querySelector('div.tooltip-inner')) {
  282. $('div.tooltip-inner').each(function() { // 遍历所有 <div> 元素
  283. var text = $(this).text(); // 获取当前元素中的文本内容
  284. if(text.includes('==')) { // 如果文本内容包含 '=='
  285. var newText = text.replace(/==/g, '\n'); // 将所有 '==' 替换为换行符
  286. $(this).text(newText); // 更新元素的文本内容
  287. console.log('replace tip !!!')
  288. }
  289. });
  290. $('div.tooltip-inner').css({'white-space':'pre', 'width':'fit-content', 'max-width':'800px', 'height':'fit-content', 'max-height':'800px'})
  291. }
  292. });
  293. observer.observe(document.body, {childList: true});
  294.  
  295.  
  296. // 使长文本中的表格支持换行符号
  297.  
  298.  
  299. waitForKeyElements ("div.longtext-modal-dialog table span", span_return);
  300. function span_return(){
  301.  
  302. console.log('span !!!')
  303.  
  304. $('div.longtext-modal-dialog table span[data-slate-string="true"]').each(function() { // 遍历所有 <span> 元素
  305. var text = $(this).text(); // 获取当前元素中的文本内容
  306. if(text.includes('■')) { // 如果文本内容包含 '■'
  307. var newText = text.replace(/■/g, '\n'); // 将所有 '■' 替换为换行符
  308. $(this).text(newText); // 更新元素的文本内容
  309. console.log('replace span !!!')
  310. }
  311. });
  312. }
  313.  
  314.  
  315. // 根据表格标题,将表格标签编译为特殊段落,比如空格或换行等
  316.  
  317.  
  318. waitForKeyElements (".tab-link", tab_link_style);
  319. function tab_link_style(){ // 记得大的数放在前面,防止小数在前时,-5删掉无法识别-50的bug
  320.  
  321. console.log('tab link style !!!')
  322.  
  323. // 子表标签透明空格,逻辑更加清晰
  324.  
  325. $('.tab-link:contains("-")').each(function( index ) {
  326. let width_str = $(this).text().replace(/^-(\d+).*/, '$1') // 提取出标题中要调整的宽度
  327. let style = {'opacity': 0.03, 'border-radius':0, 'cursor': 'inherit', 'width':width_str+'px'}
  328. let padding = parseInt(width_str) < 5 ? {'padding':0} : {'padding':'2px 1px !important'}
  329. $(this).css(Object.assign({}, style, padding))
  330. $(this).children("span.tab-title").text('​')
  331. });
  332.  
  333. // 子表标签白色竖线,逻辑更加清晰
  334.  
  335. $('.tab-link:contains("|||")').css({'padding':0.3, 'margin':'0 5px', 'border-radius':0, 'cursor': 'inherit', 'width':'5px', 'background-color':'white'})
  336. $('.tab-title:contains("|||")').text('​')
  337.  
  338. $('.tab-link:contains("||")').css({'padding':0.3, 'margin':'0 2px', 'border-radius':0, 'cursor': 'inherit', 'width':'3px', 'background-color':'white'})
  339. $('.tab-title:contains("||")').text('​')
  340.  
  341. // 子表标签换行,多行展示逻辑清晰(命名时不让用\符号)
  342.  
  343. $('.tabs-tab:contains("=n")').css({'flex-basis': '100%', 'height':'3px', 'width':'20px', 'overflow':'hidden', 'opacity':0.3})
  344. $('.tab-title:contains("=n")').text('​')
  345. }
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368. // === 废旧代码 ================================================================================
  369.  
  370.  
  371.  
  372. /* waitForKeyElements (".react-grid-Cell", grid_cell_style);
  373. function grid_cell_style(){
  374.  
  375. console.log('grid cell style !!!')
  376.  
  377. // 为单元格增加边框线
  378.  
  379. $('.react-grid-Cell:contains("世界")').css({'border-left':'solid 2px black;'})
  380.  
  381. // 人工竖直分割线
  382.  
  383. // $('.react-grid-HeaderCell:contains("---")').css({'border-bottom':0, 'background-color':'white'})
  384. // $('.react-grid-HeaderCell:contains("---") > *').css({'opacity': 0})
  385.  
  386. // $('.react-grid-Cell:contains("---")').css({'border-bottom':0})
  387. // $('.react-grid-Cell:contains("---") > *').css({'opacity': '0'})
  388.  
  389. }
  390. */
  391.  
  392.  
  393.  
  394.  
  395. // /* 将列标题中的按钮,改为下方弹出式菜单(这是旧方案,不如新方案方便快捷)
  396. // .header-cell-container .header-icon { opacity:0; position:absolute; left:-5px; padding:4px!important; margin:0; line-height:15px; border-radius: 2px; background-color:rgb(249 249 249); box-shadow:1px 2px 3px 0px #b5b5b5; } /* 平常隐藏在角落 */
  397. // .column-uneditable-tip { opacity:0; position:absolute; left:15px; padding:4px!important; margin:0 !important; line-height:15px; border-radius: 2px; background-color:rgb(249 249 249); box-shadow:1px 2px 3px 0px #b5b5b5; }
  398. // .dtable-dropdown-menu.dropdown { opacity:0; position:absolute; right:-5px;padding:4px!important; width:auto; line-height:15px; border-radius: 2px; background-color:rgb(249 249 249); box-shadow:1px 2px 3px 0px #b5b5b5; }
  399. //
  400. // .react-grid-HeaderCell:hover .header-cell-container .header-icon { opacity:1; top:30px; } /* 鼠标悬浮时显示 */
  401. // .react-grid-HeaderCell:hover .column-uneditable-tip { opacity:1; top:30px; }
  402. // .react-grid-HeaderCell:hover .dtable-dropdown-menu.dropdown { opacity:1; top:28.5px; }
  403. //
  404. // .header-cell-container .header-icon:hover { background-color:rgb(233 233 233) } /* 悬浮在按钮上时变色 */
  405. // .column-uneditable-tip:hover { background-color:rgb(233 233 233) }
  406. // .dtable-dropdown-menu.dropdown:hover { background-color:rgb(233 233 233) }
  407. // */
  408.  
  409.  
  410.  
  411.  
  412. /* CSS样式 子表标签竖向排列,更加紧致,放的更多
  413. div.tables-tabs-container div.tables-tabs-content { margin-left:0px; }
  414. div.tables-tabs-content div.tables-tabs { padding-right:0px; }
  415. div.tables-tabs-content li.tabs-tab { margin-right:0px; }
  416. div.tables-tabs-content div.tab-link { height:50px; padding:0px 0px 0px 0px!important; writing-mode:tb-rl; line-height:24px; }
  417. div.tables-tabs-content span.tab-title { font-size:14px }
  418. #header { height:30px; }
  419. #header .title { height:inherit; }
  420. .tables-tabs-container .tables-tabs-operations { width:100px; flex-wrap:wrap; margin-right:0px; }
  421. .tables-tabs-content .add-table { width:16px; margin-right:0px; }
  422. .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; }
  423. */
  424.  
  425.  
  426.  
  427.  
  428. /*--- waitForElm: 等待某元素出现,只能一次性执行 https://stackoverflow.com/questions/5525071/how-to-wait-until-an-element-exists */
  429.  
  430. // function waitForElm(selector) {
  431. // return new Promise(resolve => {
  432. // if (document.querySelector(selector)) { // 直接能找到这个元素
  433. // return resolve(document.querySelector(selector));
  434. // }
  435. //
  436. // const observer = new MutationObserver(mutations => { // 找不到这个元素时,就等待其出现
  437. // if (document.querySelector(selector)) {
  438. // observer.disconnect();
  439. // resolve(document.querySelector(selector));
  440. // }
  441. // });
  442. //
  443. // // If you get "parameter 1 is not of type 'Node'" error, see https://stackoverflow.com/a/77855838/492336
  444. // observer.observe(document.body, {
  445. // childList: true,
  446. // subtree: true
  447. // });
  448. // });
  449. // }
  450. //
  451. // await waitForElm('div.tooltip-inner').then((elm) => {
  452. // console.log('Element is ready');
  453. // console.log(elm.textContent);
  454. // });
  455.  
  456.  
  457.  
  458.  
  459. // 试图为只能填写单行数据的input增加一个textarea,填写多行内容后,将转化后的文本输入input(没有用,即使都改了,还是读不到input中的内容)
  460. //
  461. // if (document.querySelector('input.form-control') && !document.querySelector('textarea#popover-inner-textarea')) {
  462. // $('input.form-control').after(`<textarea id='popover-inner-textarea'></textarea>`)
  463. // $('textarea#popover-inner-textarea').on('change', function() {
  464. // let content = $('textarea#popover-inner-textarea').val()
  465. // $('input.form-control').attr('value', content)
  466. // $('input.form-control').val(content)
  467. // console.log(content, $('input.form-control').val())
  468. // });
  469. // }
  470.  
  471.  
  472.  
  473.  
  474.  
  475. // 渲染表格内的元素
  476. //
  477. // waitForKeyElements ("div.grid-cell-type-default", ttt);
  478. // function ttt(){
  479. // console.log('111')
  480. // }
  481. //
  482. // waitForKeyElements ("div#dtable-row-height-popover", add_custom_btns);
  483. // function add_custom_btns(){ // 渲染表格内的元素
  484. // let btn = $(`
  485. // <div class="toolbar-item ml-2 view-row-render" id="dtable-row-render-popover">
  486. // <span class="toolbar-btn view-row-render">
  487. // <i class="dtable-font dtable-icon-sync"></i>
  488. // <span>渲染</span>
  489. // </span>
  490. // </div>
  491. // `)[0];
  492. // btn.addEventListener("click", function() {
  493. // $('.grid-cell-type-default').each(function() {
  494. // $(this).html($(this).text());
  495. // });
  496. // });
  497. // $('div#dtable-row-height-popover').after(btn);
  498. // }
  499.  
  500.  
  501.  
  502.  
  503. // 使列描述中内容支持换行符号(已改为响应更加及时的MO方案)
  504. //
  505. // waitForKeyElements ("div.tooltip-inner", tip_return); // .column-description-tip
  506. // function tip_return(){ // 使列描述中内容支持换行符号
  507. // $('div.tooltip-inner').each(function() { // 遍历所有 <div> 元素
  508. // var text = $(this).text(); // 获取当前元素中的文本内容
  509. // if(text.includes('■')) { // 如果文本内容包含 '■'
  510. // var newText = text.replace(/■/g, '\n'); // 将所有 '■' 替换为换行符
  511. // $(this).text(newText); // 更新元素的文本内容
  512. // console.log('replace tip !!!')
  513. // }
  514. // });
  515. //
  516. // $('div.tooltip-inner').css({'white-space':'pre', 'width':'fit-content', 'max-width':'800px', 'height':'fit-content', 'max-height':'800px'})
  517. // }