Skip to content

Instantly share code, notes, and snippets.

@tjunghans
Created April 19, 2020 17:49
Show Gist options
  • Save tjunghans/dfe40cc12f0e4389bb70c9e8f6899f67 to your computer and use it in GitHub Desktop.
Save tjunghans/dfe40cc12f0e4389bb70c9e8f6899f67 to your computer and use it in GitHub Desktop.
RedCap
(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