Created
January 18, 2025 18:59
-
-
Save yahelc/2679d70dbdf5dca1d9824c2daf723284 to your computer and use it in GitHub Desktop.
Empower Bookmarklet to Convert Investments Into a Table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function() { | |
function convertToTable(containerClass) { | |
const container = document.querySelector(`.${containerClass}`); | |
if (!container) { | |
console.error('Container not found'); | |
return; | |
} | |
const table = document.createElement('table'); | |
table.setAttribute('border', '1'); | |
const headers = container.querySelectorAll('[role="columnheader"]'); | |
const thead = document.createElement('thead'); | |
const headerRow = document.createElement('tr'); | |
headers.forEach(header => { | |
const th = document.createElement('th'); | |
th.textContent = header.textContent.trim(); | |
headerRow.appendChild(th); | |
}); | |
thead.appendChild(headerRow); | |
table.appendChild(thead); | |
const rows = container.querySelectorAll('[role="row"]'); | |
const tbody = document.createElement('tbody'); | |
rows.forEach((row, index) => { | |
if (index === 0) return; | |
const tr = document.createElement('tr'); | |
const cells = row.querySelectorAll('[role="gridcell"]'); | |
cells.forEach(cell => { | |
const td = document.createElement('td'); | |
td.innerHTML = cell.innerHTML.trim(); | |
tr.appendChild(td); | |
}); | |
tbody.appendChild(tr); | |
}); | |
table.appendChild(tbody); | |
container.parentElement.replaceChild(table, container); | |
} | |
convertToTable('holdings-grid-table-client-container'); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment