User:Nickptar/difftable.js

// fix diff overflow expanding page

function cesarb_fixDiffOverflowTableCell(cell) {   var div = document.createElement("div"); div.style.overflow = "auto"; while (cell.firstChild) {       div.appendChild(cell.firstChild); }   cell.appendChild(div); }

function cesarb_fixDiffOverflowTable(table) {   var cells = table.getElementsByTagName("td");

for (var i = 0; i < cells.length; i++) {       var cell = cells[i]; var classes = cell.className.split(" ");

for (var j = 0; j < classes.length; j++) {           if (classes[j] == "diff-context" || classes[j] == "diff-addedline" || classes[j] == "diff-deletedline") {               cesarb_fixDiffOverflowTableCell(cell); break; }       }    } }

function cesarb_fixDiffOverflowLoadListener(evt) {   var tables = document.getElementsByTagName("table");

loop: for (var i = 0; i < tables.length; i++) {       var table = tables[i]; var classes = table.className.split(" ");

for (var j = 0; j < classes.length; j++) {           if (classes[j] == "diff") {               cesarb_fixDiffOverflowTable(table); break loop; }       }    } }

window.addEventListener("load", cesarb_fixDiffOverflowLoadListener, false);