Vibrant Row Hover Effect for Specific Columns

Add vibrant row hover effect for specific columns dynamically with black bold font

  1. // ==UserScript==
  2. // @name Vibrant Row Hover Effect for Specific Columns
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.0
  5. // @description Add vibrant row hover effect for specific columns dynamically with black bold font
  6. // @match https://his.kaauh.org/lab/*
  7. // @grant GM_addStyle
  8. // ==/UserScript==
  9.  
  10. (function () {
  11. 'use strict';
  12.  
  13. // Add CSS for hover effect
  14. GM_addStyle(`
  15. .ag-row {
  16. transition: background-color 0.3s ease;
  17. }
  18. .vibrant-hover {
  19. background-color: #87dced !important; /* Light green color */
  20. color: black !important; /* Black text color */
  21. font-weight: bold !important; /* Bold font */
  22. }
  23. `);
  24.  
  25. // List of `col-id` attributes to target (including new ones)
  26. const targetColumnIds = [
  27. "orderNo", "testId", "testDescription", "clusterMrn",
  28. "hospitalMrn", "patientName", "dob", "nationalIqamaId",
  29. "department", "clinic", "doctor", "analyzer",
  30. "orderDateAndTime", "lastUpdatedDate", "status", "sampleStatus",
  31. "referenceLab", "accessionNo", "barcode", "sequenceNo",
  32. "primaryPatientId", "referenceLabDesc", "testStatus",
  33. "orderLastModifiedOnEpoch", "orderCreatedOnEpoch", "equipmentName", "doctorName", "localMrn",
  34. "dateOfBirth", "idNumber" // Added new columns
  35. ];
  36.  
  37. // Function to add hover effects to the entire row when any target cell is hovered
  38. function applyHoverEffect() {
  39. document.querySelectorAll('.ag-cell').forEach(cell => {
  40. const colId = cell.getAttribute('col-id');
  41. if (colId && targetColumnIds.includes(colId)) {
  42. const row = cell.closest('.ag-row'); // Find the parent row
  43. if (row) {
  44. // Add hover effect to the entire row on mouseenter
  45. cell.addEventListener('mouseenter', () => {
  46. row.classList.add('vibrant-hover'); // Add hover effect to the row
  47. });
  48. // Remove hover effect on mouseleave
  49. cell.addEventListener('mouseleave', () => {
  50. row.classList.remove('vibrant-hover'); // Remove hover effect from the row
  51. });
  52. }
  53. }
  54. });
  55. }
  56.  
  57. // Reapply hover effects when rows are dynamically updated
  58. const observer = new MutationObserver(() => {
  59. applyHoverEffect(); // Ensure hover effect is applied to all new rows
  60. });
  61.  
  62. observer.observe(document.body, { childList: true, subtree: true });
  63.  
  64. // Initial application of hover effect
  65. window.addEventListener('load', applyHoverEffect);
  66. })();
  67.  
  68.  
  69.  
  70. // Function to set the dropdown value
  71. (function() {
  72. 'use strict';
  73.  
  74. // Function to set the dropdown value
  75. function setDropdownValue() {
  76. const dropdown = document.getElementById("dropdownPaginationPageSize");
  77. if (dropdown && dropdown.value !== "100") {
  78. dropdown.value = "100"; // Set the value to "100"
  79.  
  80. // Trigger the 'change' event
  81. const event = new Event('change', { bubbles: true });
  82. dropdown.dispatchEvent(event);
  83.  
  84. console.log("Dropdown value set to 100");
  85. }
  86. }
  87.  
  88. // Function to observe changes in the DOM
  89. function observeDOM() {
  90. const observer = new MutationObserver(() => {
  91. setDropdownValue(); // Check and set the dropdown value when changes are detected
  92. });
  93.  
  94. // Observe the entire document for changes
  95. observer.observe(document.body, {
  96. childList: true,
  97. subtree: true,
  98. });
  99.  
  100. console.log("MutationObserver is active");
  101. }
  102.  
  103. // Run the function when the page is fully loaded
  104. window.addEventListener('load', () => {
  105. setDropdownValue(); // Initial check
  106. observeDOM(); // Start observing for dynamic changes
  107. });
  108. })();

QingJ © 2025

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