User:Nickptar~enwikibooks/monobook.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);

// edit top

function editTopLink { // if this is a preview page, stop if(document.getElementById("wikiPreview") || self.location.pathname.indexOf("title=Special:") !== -1) { return; }

// get the page title var pageTitle = document.title.split(" - ")[0].replace(" ", "_");

// create div and set innerHTML to link var divContainer = document.createElement("div"); divContainer.innerHTML = ' [edit top] ';

// this is a hack so I can refer to the h1 by an id document.getElementsByTagName("h1")[0].id = "f1r5tH34d1ng"; var theH1 = document.getElementById("f1r5tH34d1ng");

// insert divContainer into the DOM before the h1 document.getElementById("content").insertBefore(divContainer, theH1);

}

// setTimeout does not need a string reference to work setTimeout(editTopLink, 0) // this is equivalent of onload