Created
April 19, 2020 17:49
-
-
Save tjunghans/dfe40cc12f0e4389bb70c9e8f6899f67 to your computer and use it in GitHub Desktop.
RedCap
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
(function () { | |
"use strict"; | |
const table = document.querySelector("table"); | |
if (table) { | |
const thead = table.querySelector("thead"); | |
const tbody = table.querySelector("tbody"); | |
// create "Path" header column | |
const pathHeader = document.createElement("th"); | |
pathHeader.textContent = "Path"; | |
// append th (table header) element after "Filename"" | |
thead.querySelectorAll("th")[3].after(pathHeader); | |
const rows = tbody.querySelectorAll("tr"); | |
// iterate over all data rows | |
for (const row of rows) { | |
// create a new column | |
const pathData = document.createElement("td"); | |
// copy the link (href) vale of the Filename column to the new column | |
pathData.textContent = row.querySelectorAll("td")[3].querySelector("a").getAttribute("href"); | |
// append the new column | |
row.querySelectorAll("td")[3].after(pathData); | |
} | |
} | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment