diff --git a/browser-extension/addTableSortClass.js b/browser-extension/addTableSortClass.js
index 39f0396..441872f 100644
--- a/browser-extension/addTableSortClass.js
+++ b/browser-extension/addTableSortClass.js
@@ -1,14 +1,7 @@
document.body.style.border = "1px solid red";
-function getTables() {
- return document.querySelectorAll("table");
-}
-let tables = getTables();
-console.log("tables", tables);
-function addTableSortClass() {
- let tablesWithTableSortClass = Array.from(tables).map((table) => {
- return table.classList.add("table-sort");
- });
- return tablesWithTableSortClass;
-}
-addTableSortClass();
+let tables = document.querySelectorAll("table");
+
+Array.from(tables).map((table) => {
+ return table.classList.add("table-sort");
+});
diff --git a/browser-extension/getTableHeaders.js b/browser-extension/getTableHeaders.js
deleted file mode 100644
index 1c9f15c..0000000
--- a/browser-extension/getTableHeaders.js
+++ /dev/null
@@ -1,7 +0,0 @@
-function getTableHeaders() {
- let headers = document.querySelectorAll("table th");
- let headerNames = Array.from(headers).map((header) => header.innerText);
- console.log("test", headerNames);
- return headerNames;
-}
-getTableHeaders();
diff --git a/browser-extension/manifest.json b/browser-extension/manifest.json
index adbbb61..026d05b 100644
--- a/browser-extension/manifest.json
+++ b/browser-extension/manifest.json
@@ -7,8 +7,7 @@
"icons": { "48": "icons/t.png" },
"browser_action": {
"default_icon": "./icons/t.png",
- "default_title": "table-sort",
- "default_popup": "popup/table-options.html"
+ "default_title": "table-sort-js"
},
"content_scripts": [
{
@@ -17,7 +16,7 @@
"*://*.mozilla.org/*",
"https://github.com/*/*/actions/runs/*/usage"
],
- "js": ["addTableSortClass.js", "getTableHeaders.js", "table-sort.js"]
+ "js": ["addTableSortClass.js", "table-sort.js"]
}
]
}
diff --git a/browser-extension/popup/table-options.html b/browser-extension/popup/table-options.html
deleted file mode 100644
index 035a745..0000000
--- a/browser-extension/popup/table-options.html
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
- Popup
-
-
-
-
-
-
diff --git a/browser-extension/setButtons.js b/browser-extension/setButtons.js
deleted file mode 100644
index e35db9e..0000000
--- a/browser-extension/setButtons.js
+++ /dev/null
@@ -1,16 +0,0 @@
-// let tables = window.document.querySelectorAll("table");
-// console.log(getTableHeaders())
-let headers = document.querySelectorAll("table th");
-console.log(headers);
-let headerNames = Array.from(headers).map((header) => header.innerText);
-console.log("nnnn");
-
-headerNames.forEach((name) => {
- const btn = document.createElement("button");
- console.log(name);
- btn.innerText = name;
-
- document.querySelector("#popup-content").appendChild(btn);
- let test = document.querySelector("#popup-content");
- console.log(test);
-});
diff --git a/browser-extension/table-sort.js b/browser-extension/table-sort.js
index fecf815..660bffc 100644
--- a/browser-extension/table-sort.js
+++ b/browser-extension/table-sort.js
@@ -177,30 +177,40 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
}
function sortByRuntime(tableRows, columnData) {
- for (let [i, tr] of tableRows.entries()) {
- const regexMinutesAndSeconds = /^(\d+h)?\s?(\d+m)?\s?(\d+s)?$/i;
- let columnOfTd = tr
- .querySelectorAll("td")
- .item(columnIndex).textContent;
- let match = columnOfTd.match(regexMinutesAndSeconds);
- let [minutesInSeconds, hours, seconds, timeinSeconds] = [0, 0, 0, 0];
- if (match) {
- const regexHours = match[1];
- if (regexHours) {
- hours = Number(regexHours.replace("h", "")) * 60 * 60;
- }
- const regexMinutes = match[2];
- if (regexMinutes) {
- minutesInSeconds = Number(regexMinutes.replace("m", "")) * 60;
+ try {
+ for (let [i, tr] of tableRows.entries()) {
+ const regexMinutesAndSeconds = /^(\d+h)?\s?(\d+m)?\s?(\d+s)?$/i;
+ let columnOfTd = "";
+ // TODO: github actions runtime didn't like textContent, tests didn't like innerText?
+ if (testingTableSortJS) {
+ columnOfTd = tr
+ .querySelectorAll("td")
+ .item(columnIndex).textContent;
+ } else {
+ columnOfTd = tr.querySelectorAll("td").item(columnIndex).innerText;
}
- const regexSeconds = match[3];
- if (regexSeconds) {
- seconds = Number(regexSeconds.replace("s", ""));
+ let match = columnOfTd.match(regexMinutesAndSeconds);
+ let [minutesInSeconds, hours, seconds, timeinSeconds] = [0, 0, 0, 0];
+ if (match) {
+ const regexHours = match[1];
+ if (regexHours) {
+ hours = Number(regexHours.replace("h", "")) * 60 * 60;
+ }
+ const regexMinutes = match[2];
+ if (regexMinutes) {
+ minutesInSeconds = Number(regexMinutes.replace("m", "")) * 60;
+ }
+ const regexSeconds = match[3];
+ if (regexSeconds) {
+ seconds = Number(regexSeconds.replace("s", ""));
+ }
+ timeinSeconds = hours + minutesInSeconds + seconds;
}
- timeinSeconds = hours + minutesInSeconds + seconds;
+ columnData.push(`${timeinSeconds}#${i}`);
+ columnIndexAndTableRow[columnData[i]] = tr.innerHTML;
}
- columnData.push(`${timeinSeconds}#${i}`);
- columnIndexAndTableRow[columnData[i]] = tr.innerHTML;
+ } catch (e) {
+ console.log(e);
}
}
diff --git a/npm/table-sort.js b/npm/table-sort.js
index fecf815..660bffc 100644
--- a/npm/table-sort.js
+++ b/npm/table-sort.js
@@ -177,30 +177,40 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
}
function sortByRuntime(tableRows, columnData) {
- for (let [i, tr] of tableRows.entries()) {
- const regexMinutesAndSeconds = /^(\d+h)?\s?(\d+m)?\s?(\d+s)?$/i;
- let columnOfTd = tr
- .querySelectorAll("td")
- .item(columnIndex).textContent;
- let match = columnOfTd.match(regexMinutesAndSeconds);
- let [minutesInSeconds, hours, seconds, timeinSeconds] = [0, 0, 0, 0];
- if (match) {
- const regexHours = match[1];
- if (regexHours) {
- hours = Number(regexHours.replace("h", "")) * 60 * 60;
- }
- const regexMinutes = match[2];
- if (regexMinutes) {
- minutesInSeconds = Number(regexMinutes.replace("m", "")) * 60;
+ try {
+ for (let [i, tr] of tableRows.entries()) {
+ const regexMinutesAndSeconds = /^(\d+h)?\s?(\d+m)?\s?(\d+s)?$/i;
+ let columnOfTd = "";
+ // TODO: github actions runtime didn't like textContent, tests didn't like innerText?
+ if (testingTableSortJS) {
+ columnOfTd = tr
+ .querySelectorAll("td")
+ .item(columnIndex).textContent;
+ } else {
+ columnOfTd = tr.querySelectorAll("td").item(columnIndex).innerText;
}
- const regexSeconds = match[3];
- if (regexSeconds) {
- seconds = Number(regexSeconds.replace("s", ""));
+ let match = columnOfTd.match(regexMinutesAndSeconds);
+ let [minutesInSeconds, hours, seconds, timeinSeconds] = [0, 0, 0, 0];
+ if (match) {
+ const regexHours = match[1];
+ if (regexHours) {
+ hours = Number(regexHours.replace("h", "")) * 60 * 60;
+ }
+ const regexMinutes = match[2];
+ if (regexMinutes) {
+ minutesInSeconds = Number(regexMinutes.replace("m", "")) * 60;
+ }
+ const regexSeconds = match[3];
+ if (regexSeconds) {
+ seconds = Number(regexSeconds.replace("s", ""));
+ }
+ timeinSeconds = hours + minutesInSeconds + seconds;
}
- timeinSeconds = hours + minutesInSeconds + seconds;
+ columnData.push(`${timeinSeconds}#${i}`);
+ columnIndexAndTableRow[columnData[i]] = tr.innerHTML;
}
- columnData.push(`${timeinSeconds}#${i}`);
- columnIndexAndTableRow[columnData[i]] = tr.innerHTML;
+ } catch (e) {
+ console.log(e);
}
}
diff --git a/public/table-sort.js b/public/table-sort.js
index 4a707b4..660bffc 100644
--- a/public/table-sort.js
+++ b/public/table-sort.js
@@ -181,9 +181,11 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
for (let [i, tr] of tableRows.entries()) {
const regexMinutesAndSeconds = /^(\d+h)?\s?(\d+m)?\s?(\d+s)?$/i;
let columnOfTd = "";
- // TODO: github actions runtime didn't like textContent, tests didn't like innerText?
+ // TODO: github actions runtime didn't like textContent, tests didn't like innerText?
if (testingTableSortJS) {
- columnOfTd = tr.querySelectorAll("td").item(columnIndex).textContent;
+ columnOfTd = tr
+ .querySelectorAll("td")
+ .item(columnIndex).textContent;
} else {
columnOfTd = tr.querySelectorAll("td").item(columnIndex).innerText;
}