Avoid copying the table and use querySelector()
(Since there's only one .articleBody.)
This commit is contained in:
parent
7a61a6a5b4
commit
58ef7600fb
|
@ -23,14 +23,13 @@ function convertImgSrc() {
|
||||||
|
|
||||||
// Wrap tables in an overflow-x: auto; div
|
// Wrap tables in an overflow-x: auto; div
|
||||||
function wrapTables() {
|
function wrapTables() {
|
||||||
var tables = document.querySelectorAll("div.articleBody")[0].getElementsByTagName("table");
|
var tables = document.querySelector("div.articleBody").getElementsByTagName("table");
|
||||||
|
|
||||||
for (table of tables) {
|
for (table of tables) {
|
||||||
var wrapper = document.createElement("div");
|
var wrapper = document.createElement("div");
|
||||||
wrapper.className = "nnw-overflow";
|
wrapper.className = "nnw-overflow";
|
||||||
var tableCopy = table.cloneNode(true);
|
table.parentNode.insertBefore(wrapper, table);
|
||||||
wrapper.appendChild(tableCopy);
|
wrapper.appendChild(table);
|
||||||
table.parentNode.replaceChild(wrapper, table);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue