您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add a button to toggle specific columns in AG Grid. Only visible on a specific page, located within the sidebar buttons container if present, with color change when toggled.
当前为
// ==UserScript== // @name Movable Button for Column Selector in AG Grid // @version 1.5 // @description Add a button to toggle specific columns in AG Grid. Only visible on a specific page, located within the sidebar buttons container if present, with color change when toggled. // @match *://his.kaauh.org/lab/* // @author Hamad AlShegifi // @grant none // @namespace http://tampermonkey.net/ // ==/UserScript== (function () { 'use strict'; const columnsToUncheck = [ 'Lab Order No', 'Hospital MRN', 'DOB', 'Test ID', 'National/Iqama Id', 'Department', 'Clinic', 'Doctor', 'Analyzer', 'Reference Lab', 'Accession No', 'Sequence No' ]; let hasRunOnce = false; // Prevents running the code more than once function isSpecificPage() { return window.location.pathname.endsWith('/lab-orders/lab-test-analyzer'); } function areColumnsChecked() { return columnsToUncheck.some(column => isColumnChecked(column)); } function isColumnChecked(labelText) { const labels = document.querySelectorAll('.ag-column-tool-panel-column-label'); for (const label of labels) { if (label.textContent.trim() === labelText) { const checkbox = label.parentElement.querySelector('.ag-icon-checkbox-checked'); if (checkbox) return true; // Column is checked } } return false; // Column is not checked } function ensureColumnsUnchecked() { if (hasRunOnce) return; if (!areColumnsChecked()) return; // Do nothing if columns are not checked hasRunOnce = true; console.log("Unchecking checked columns..."); setTimeout(() => { columnsToUncheck.forEach(column => clickColumnLabel(column)); }, 1000); } function ensureOtherColumnsChecked() { console.log("Ensuring all other columns are checked..."); const allLabels = document.querySelectorAll('.ag-column-tool-panel-column-label'); allLabels.forEach(label => { const labelText = label.textContent.trim(); if (!columnsToUncheck.includes(labelText)) { const checkbox = label.parentElement.querySelector('.ag-icon-checkbox-unchecked'); if (checkbox) { label.click(); // Click to check the column if unchecked } } }); } function clickColumnLabel(labelText) { const labels = document.querySelectorAll('.ag-column-tool-panel-column-label'); labels.forEach(label => { if (label.textContent.trim() === labelText) { const checkbox = label.parentElement.querySelector('.ag-icon-checkbox-checked'); if (checkbox) { label.click(); // Click only if checked } } }); } function initOnce() { if (!isSpecificPage()) return; console.log("Checking if columns need to be unchecked..."); let attempts = 0; const interval = setInterval(() => { if (document.querySelector('.ag-side-buttons')) { ensureColumnsUnchecked(); ensureOtherColumnsChecked(); clearInterval(interval); } if (++attempts > 10) clearInterval(interval); }, 500); } const observer = new MutationObserver(() => { if (isSpecificPage()) { hasRunOnce = false; // Reset run flag for repeated executions initOnce(); } }); observer.observe(document.body, { childList: true, subtree: true }); if (isSpecificPage()) { initOnce(); } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址