User:Splarka/stripsource.js

//script for generating a stripped version of a wikipage for local testing/modification

var getReq; function retrieveURL(url) { if (window.XMLHttpRequest) { // Non-IE browsers getReq = new XMLHttpRequest; } else if (window.ActiveXObject) { // IE   getReq = new ActiveXObject('Microsoft.XMLHTTP'); } if (getReq) { //Define 'callback' function getReq.onreadystatechange = processStateChange; try { getReq.open('GET', url, true); getReq.send(''); } catch (e) { alert(e); } } else { alert('XMLHTTPRequest not supported'); } }

function processStateChange { switch (getReq.readyState) { case 1: break; case 2: break; case 3: break; case 4: if (getReq.status == 200) { // OK response parseXML(getReq.responseText); } else { alert('Problem: ' + getReq.statusText); }     break; } }

function parseXML(data) { var base = data.substring(data.indexOf('var wgServer')+16,data.indexOf('var wgCanonicalNamespace')-3); var source = data; var rxp = [ /\<\!\-\- attempt to fetch [^>]*\-\-\>\n/ig, /\<\!\-\- right column \(google ads\) BEGIN \-\-\>[^¿]*\<\!\-\- right column \(google ads\) END \-\-\>/ig, /\<\!\-\- Served by [^¿]*\<\!\-\- analytics \(end\) \-\-\>/ig, /\.*\<\/li\>\n/ig, /\.*\<\/li\>\n/ig, /\[^<]{0,3}var reqSendToAFriend[^<]*\< 50[^<]*\<\/script\>/ig, /\[^¿]*\<\/script\>\<\/div\>/ig ] for(var i=0;i < rxp.length;i++) { source = source.replace(rxp[i],''); }

source = source.replace(' ',' '); // document.getElementById('wpTextbox1').value = source; }