Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
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.
//DOWNLOADERfunctionnewXml(){returnwindow.XMLHttpRequest?newXMLHttpRequest():window.ActiveXObject?newActiveXObject("Microsoft.XMLHTTP"):false;}functionblind_download(bundle){// mandatory: bundle.url// bundle.onSuccess // bundle.onFailure// bundle.otherStuff OK toovarx=newXml();if(x){if(x.overrideMimeType){x.overrideMimeType('text/xml');}// else alert('Unable to override mime type - this will probably fail.');x.onreadystatechange=function(){x.readyState==4&&blind_downloadComplete(x,bundle);};x.open("GET",bundle.url,true);// x.setRequestHeader('Accept','text/*');x.send(null);}}functionblind_downloadComplete(x,bundle){x.status==200&&(bundle.onSuccess&&bundle.onSuccess(x,bundle)||true)||(bundle.onFailure&&bundle.onFailure(x,bundle)||alert(x.statusText));}functionblind_post(bundle){// mandatory: bundle.url// bundle.onSuccess // bundle.onFailure// bundle.data (to be sent) - array of objects { name: 'wpStartTime', data: '20051111091512' }// bundle.otherStuff OK toovarx=newXml();if(x){x.onreadystatechange=function(){x.readyState==4&&blind_downloadComplete(x,bundle);};x.open("POST",bundle.url,true);varsendMe='';for(vari=0;i<bundle.data.length;++i){if(!bundle.data[i])continue;if(sendMe.length>0)sendMe+='&';sendMe+=URLEncode(bundle.data[i].name)+'='+URLEncode(bundle.data[i].data);}x.setRequestHeader('Content-Type','application/x-www-form-urlencoded');//alert(sendMe);x.send(sendMe);}}// Source: http://www.albionresearch.com/misc/urlencode.phpfunctionURLEncode(plaintext){// The Javascript escape and unescape functions do not correspond// with what browsers actually do...varSAFECHARS="0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz"+"-_.!~*'()";varHEX="0123456789ABCDEF";varencoded="";for(vari=0;i<plaintext.length;i++){varch=plaintext.charAt(i);if(ch==" "){encoded+="+";// x-www-urlencoded, rather than %20}elseif(SAFECHARS.indexOf(ch)!=-1){encoded+=ch;}else{varcharCode=ch.charCodeAt(0);if(charCode>255){alert("Unicode Character '"+ch+"' cannot be encoded using standard URL encoding.\n"+"(URL encoding only supports 8-bit characters.)\n"+"A space (+) will be substituted.");encoded+="+";}else{encoded+="%";encoded+=HEX.charAt((charCode>>4)&0xF);encoded+=HEX.charAt(charCode&0xF);}}}// forreturnencoded;}window.harvestNamedChildren=function(node){varret=[];for(vari=0;i<node.childNodes.length;++i){varchild=node.childNodes[i];if(child.nodeType!=1)continue;varchildName=child.getAttribute('name');if(!childName||typeofchildName!=typeof'')continue;if(childName=='wpTextbox1'){varwikiData=child.childNodes[0].data;ret.push({name:'wpTextbox1',data:wikiData});}elseif(child.getAttribute('checked')){ret.push({name:childName,data:(child.getAttribute('checked')=='checked'?'on':'off')});}else{ret.push({name:child.getAttribute('name'),data:child.getAttribute('value')});}if(child.childNodes.length>0)ret=ret.concat(harvestNamedChildren(child));}returnret;}window.getXmlObj=function(req){if(req.responseXML&&req.responseXML.documentElement)returnreq.responseXML;// Note: this doesn't work in konqueror, and the natural fix// var doc=document.implementation.createDocument(); doc.loadXML(req.responseXML)// results in a segfault :-(try{doc=newActiveXObject("Microsoft.XMLDOM");doc.async="false";doc.loadXML(req.responseText);}catch(err){returnnull;}returndoc;}window.processEditPage=function(req,bundle){// alert(req.responseText);// alert(req.responseXML);varxmlobj=getXmlObj(req);if(!xmlobj){alert('could not get xml :-(');}vardoc=xmlobj.documentElement;if(!doc){alert('could not get xml documentElement. grrrr');}varforms=doc.getElementsByTagName('form');if(!forms.length)alert('No forms found. Bailing...');varform=null;for(vari=0;i<forms.length;++i){if(forms[i].getAttribute('name')=='editform'){form=forms[i];break;}}if(!form)alert('No edit form found. Darn.');varaction=form.getAttribute('action');varpostUrl=action;// if the url doesn't include the hostname, we have to fix that. probably.if(action.indexOf('http')!=0){postUrl=bundle.url.split('/');postUrl=[postUrl[0],postUrl[1],postUrl[2]].join('/')+action;}//alert(postUrl);varformData=harvestNamedChildren(form);for(vari=0;i<formData.length;++i){if(!formData[i])continue;switch(formData[i].name){case'wpTextbox1':if(bundle.processWikiData){formData[i].data=bundle.processWikiData(formData[i].data);}break;case'wpPreview':case'wpDiff':formData[i]=null;break;}}blind_post({data:formData,url:postUrl,onSuccess:function(req,b){alert(req.responseText);}});}functiontestblind(){varurl='http://en.wikipedia.org/wiki/User:Lupin/sandbox?action=edit';blind_download({url:url,onSuccess:processEditPage,processWikiData:function(txt){return'hello!'+Math.random()+'\n\n'+txt;}});}/// Local Variables: ////// mode:c ////// End: ///