Skip to content

Commit 402d8ae

Browse files
Version 1.20.0
1 parent 8d5d500 commit 402d8ae

File tree

5 files changed

+30
-27
lines changed

5 files changed

+30
-27
lines changed
-1 Bytes
Binary file not shown.

browser-extensions/chrome/table-sort.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
8282
break;
8383
}
8484
const tableColumn = tr
85-
.querySelectorAll("td")
85+
.querySelectorAll("* > th , * > td")
8686
.item(
8787
column.span[columnIndex] === 1
8888
? column.spanSum[columnIndex] - 1
@@ -125,11 +125,9 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
125125
headers: [],
126126
};
127127
for (let index of table.theads.keys()) {
128-
if (table.theads.item(index).querySelectorAll("th").length == 0) {
129-
table.headers.push(table.theads.item(index).querySelectorAll("td"));
130-
} else {
131-
table.headers.push(table.theads.item(index).querySelectorAll("th"));
132-
}
128+
table.headers.push(
129+
table.theads.item(index).querySelectorAll("* > th , * > td")
130+
);
133131
}
134132
for (let index of table.bodies.keys()) {
135133
if (table.bodies.item(index) == null) {
@@ -200,7 +198,9 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
200198
};
201199
const numberWithUnitType = /([.0-9]+)\s?(B|KB|KiB|MB|MiB|GB|GiB|TB|TiB)/i;
202200
for (let [i, tr] of table.visibleRows.entries()) {
203-
let fileSizeTd = tr.querySelectorAll("td").item(columnIndex).textContent;
201+
let fileSizeTd = tr
202+
.querySelectorAll("* > th , * > td")
203+
.item(columnIndex).textContent;
204204
let match = fileSizeTd.match(numberWithUnitType);
205205
if (match) {
206206
let number = parseFloat(match[1]);
@@ -465,7 +465,8 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
465465
"NaN"
466466
);
467467
}
468-
tr.querySelectorAll("td").item(columnIndex).innerHTML = fileSizeInBytesHTML;
468+
tr.querySelectorAll("* > th , * > td").item(columnIndex).innerHTML =
469+
fileSizeInBytesHTML;
469470
return table.hasClass.cellsSort ? tr.innerHTML : tr.outerHTML;
470471
}
471472

@@ -532,7 +533,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
532533
const column = {
533534
getColumn: function getColumn(tr, colSpanSum, colSpanData) {
534535
return tr
535-
.querySelectorAll("td")
536+
.querySelectorAll("* > th , * > td")
536537
.item(
537538
colSpanData[columnIndex] === 1
538539
? colSpanSum[columnIndex] - 1
-1 Bytes
Binary file not shown.

browser-extensions/firefox/table-sort.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
8282
break;
8383
}
8484
const tableColumn = tr
85-
.querySelectorAll("td")
85+
.querySelectorAll("* > th , * > td")
8686
.item(
8787
column.span[columnIndex] === 1
8888
? column.spanSum[columnIndex] - 1
@@ -125,11 +125,9 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
125125
headers: [],
126126
};
127127
for (let index of table.theads.keys()) {
128-
if (table.theads.item(index).querySelectorAll("th").length == 0) {
129-
table.headers.push(table.theads.item(index).querySelectorAll("td"));
130-
} else {
131-
table.headers.push(table.theads.item(index).querySelectorAll("th"));
132-
}
128+
table.headers.push(
129+
table.theads.item(index).querySelectorAll("* > th , * > td")
130+
);
133131
}
134132
for (let index of table.bodies.keys()) {
135133
if (table.bodies.item(index) == null) {
@@ -200,7 +198,9 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
200198
};
201199
const numberWithUnitType = /([.0-9]+)\s?(B|KB|KiB|MB|MiB|GB|GiB|TB|TiB)/i;
202200
for (let [i, tr] of table.visibleRows.entries()) {
203-
let fileSizeTd = tr.querySelectorAll("td").item(columnIndex).textContent;
201+
let fileSizeTd = tr
202+
.querySelectorAll("* > th , * > td")
203+
.item(columnIndex).textContent;
204204
let match = fileSizeTd.match(numberWithUnitType);
205205
if (match) {
206206
let number = parseFloat(match[1]);
@@ -465,7 +465,8 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
465465
"NaN"
466466
);
467467
}
468-
tr.querySelectorAll("td").item(columnIndex).innerHTML = fileSizeInBytesHTML;
468+
tr.querySelectorAll("* > th , * > td").item(columnIndex).innerHTML =
469+
fileSizeInBytesHTML;
469470
return table.hasClass.cellsSort ? tr.innerHTML : tr.outerHTML;
470471
}
471472

@@ -532,7 +533,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
532533
const column = {
533534
getColumn: function getColumn(tr, colSpanSum, colSpanData) {
534535
return tr
535-
.querySelectorAll("td")
536+
.querySelectorAll("* > th , * > td")
536537
.item(
537538
colSpanData[columnIndex] === 1
538539
? colSpanSum[columnIndex] - 1

npm/table-sort.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
8282
break;
8383
}
8484
const tableColumn = tr
85-
.querySelectorAll("td")
85+
.querySelectorAll("* > th , * > td")
8686
.item(
8787
column.span[columnIndex] === 1
8888
? column.spanSum[columnIndex] - 1
@@ -125,11 +125,9 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
125125
headers: [],
126126
};
127127
for (let index of table.theads.keys()) {
128-
if (table.theads.item(index).querySelectorAll("th").length == 0) {
129-
table.headers.push(table.theads.item(index).querySelectorAll("td"));
130-
} else {
131-
table.headers.push(table.theads.item(index).querySelectorAll("th"));
132-
}
128+
table.headers.push(
129+
table.theads.item(index).querySelectorAll("* > th , * > td")
130+
);
133131
}
134132
for (let index of table.bodies.keys()) {
135133
if (table.bodies.item(index) == null) {
@@ -200,7 +198,9 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
200198
};
201199
const numberWithUnitType = /([.0-9]+)\s?(B|KB|KiB|MB|MiB|GB|GiB|TB|TiB)/i;
202200
for (let [i, tr] of table.visibleRows.entries()) {
203-
let fileSizeTd = tr.querySelectorAll("td").item(columnIndex).textContent;
201+
let fileSizeTd = tr
202+
.querySelectorAll("* > th , * > td")
203+
.item(columnIndex).textContent;
204204
let match = fileSizeTd.match(numberWithUnitType);
205205
if (match) {
206206
let number = parseFloat(match[1]);
@@ -465,7 +465,8 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
465465
"NaN"
466466
);
467467
}
468-
tr.querySelectorAll("td").item(columnIndex).innerHTML = fileSizeInBytesHTML;
468+
tr.querySelectorAll("* > th , * > td").item(columnIndex).innerHTML =
469+
fileSizeInBytesHTML;
469470
return table.hasClass.cellsSort ? tr.innerHTML : tr.outerHTML;
470471
}
471472

@@ -532,7 +533,7 @@ function tableSortJs(testingTableSortJS = false, domDocumentWindow = document) {
532533
const column = {
533534
getColumn: function getColumn(tr, colSpanSum, colSpanData) {
534535
return tr
535-
.querySelectorAll("td")
536+
.querySelectorAll("* > th , * > td")
536537
.item(
537538
colSpanData[columnIndex] === 1
538539
? colSpanSum[columnIndex] - 1

0 commit comments

Comments
 (0)