User:Frietjes/remove infoboxes.js

// Experimental code jQuery(document).ready(function($) { mw.loader.using(['mediawiki.util']).done( function {

function removeInfoboxes { var tableIndex = 0; var infoboxBoxes = {}; var Tables = document.getElementsByTagName( 'table' ); var i;

for ( i = 0; i < Tables.length; i++ ) { if ( $( Tables[i] ).hasClass( 'infobox' ) ) { var Rows = Tables[i].getElementsByTagName( 'tr' ); for ( j = 0; j < Rows.length; j++) { var l = Rows[j].getElementsByTagName( 'th' )[0]; var c = Rows[j].getElementsByTagName( 'td' )[0]; if ( c && !l) { if( c.getElementsByTagName('img')[0] ) { var w = (c.getElementsByTagName('img')[0]).width; var idiv = document.createElement('div'); idiv.className = "thumb tright"; var d = document.createElement('div'); d.className = "thumbinner"; d.style.width = (w + 2) + 'px'; d.innerHTML = c.innerHTML; var captions = d.getElementsByTagName('div'); for ( k = 0; k < captions.length; k++) { (captions[k]).className = "thumbcaption"; }						idiv.appendChild(d); (Tables[i].parentElement).insertBefore(idiv, Tables[i]); break; }				}			}			(Tables[i].parentElement).removeChild(Tables[i]); }   } } $( removeInfoboxes );

}); });