User:Topaz/sectionsplitter.js

Source: Wikipedia, the free encyclopedia.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
topaz.sectionsplitter = new Object();
topaz.sectionsplitter.oldonload = window.onload;
window.onload = function() {
  if (typeof topaz.sectionsplitter.oldonload == "function") topaz.sectionsplitter.oldonload();

  var bc = topaz.util.getobj("bodyContent");
  var bcn = topaz.util.getobj("bodyContent").childNodes;
  var bcnl = bcn.length;
  var curdiv = topaz.util.add(bc, "div", {className:"tz-primarySection"});
  for(var i=0;i<bcnl;i++) {
    if (bcn[0].nodeName == "H2") {
      curdiv = topaz.util.add(bc, "div", {className:"tz-primarySection"});
    }
    curdiv.appendChild(bcn[0]);
  }
}