MCPcopy Create free account
hub / github.com/ChinaGodMan/UserScripts / applyGradientToColumn

Function applyGradientToColumn

colorful-table/colorful-table.user.js:141–151  ·  view source on GitHub ↗
(table, column)

Source from the content-addressed store, hash-verified

139 const SATURATION = '80%'
140 const LIGHTNESS = '88%'
141 function applyGradientToColumn(table, column) {
142 const rowCount = table.rows.length
143 Array.from(table.rows).forEach((row, index) => {
144 const cell = row.cells[column]
145 if (!cell) return
146 // Calculate a hue based on the row index (no need to rely on cell content)
147 const hue = (index / (rowCount - 1)) * HUE_RANGE
148 // Apply the gradient color to the cell
149 cell.style.backgroundColor = `hsl(${HUE_RANGE - hue}, ${SATURATION}, ${LIGHTNESS})`
150 })
151 }
152 function initializeTable(table) {
153 if (table.hasAttribute('data-gradient-initialized')) return
154 table.setAttribute('data-gradient-initialized', 'true')

Callers 1

initializeTableFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected