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.
varrcp_http;varrcp_enabled;varrcp_num_pages;varrcp_refresh;$(rcp_init);/* initalise */functionrcp_init(){// allow user settings throughif(rcp_enabled==null){rcp_enabled=false;}if(rcp_num_pages==null){rcp_num_pages=10;}if(rcp_refresh==null){rcp_refresh=5;}// A few limits to be nice to the serversif(rcp_num_pages>50){rcp_num_pages=50;}if(rcp_num_pages<1){rcp_num_pages=1;}if(rcp_refresh<2){rcp_refresh=2;}// get our cookieif(document.cookie.length>0){varc_start=document.cookie.indexOf("rcp_show_box=");if(c_start!=-1){c_start=c_start+13;varc_end=document.cookie.indexOf(";",c_start);if(c_end==-1){c_end=document.cookie.length;}if(document.cookie.substring(c_start,c_end)=="yes"){rcp_enabled=true;}else{rcp_enabled=false;}}}// Either make a request or show nothingif(rcp_enabled==true){rcp_ajax_request();}else{rcp_draw_disabled_box();}}/* init ajax */functionrcp_create_request(){try{rcp_http=newXMLHttpRequest();}catch(e){try{rcp_http=newActiveXObject("Msxml2.XMLHTTP");}catch(e){try{rcp_http=newActiveXObject("Microsoft.XMLHTTP");}catch(e){alert("Your browser does not support AJAX!");returnfalse;}}}rcp_http.onreadystatechange=function(){if(rcp_http.readyState==4)rcp_ajax_response();}returntrue;}/* make a request */functionrcp_ajax_request(){// check we are enabledif(rcp_enabled==false)return;// firstly, inform the uservarcur_box=document.getElementById('p-recentchanges');if(cur_box!=null){cur_box.firstChild.firstChild.data='Recent Changes (updating)';}if(rcp_create_request()==false){if(cur_box!=null){cur_box.firstChild.firstChild.data='Recent Changes (update failed)';}else{alert("There seems to be a problem using the RecentChangePatrol script. I can't make AJAX objects, so I'm just going to complain. God Bless!");}}// Then make the requestrcp_http.open("GET","http://en.wikipedia.org/w/api.php?action=query&list=recentchanges&format=xml&rcnamespace=0&rcshow=!bot&rcshow=!minor&rclimit="+rcp_num_pages,true);rcp_http.send(null);}/* we have received a response */functionrcp_ajax_response(){varitems=rcp_http&&rcp_http.responseXML?rcp_http.responseXML.getElementsByTagName('rc'):[];// create the div that holds all the recentchanges linksvarlink_div=document.createElement('div');link_div.className='pBody';varlist=document.createElement('ul');link_div.appendChild(list);// populate the list with 10 links.for(vari=0;i<items.length;i++){varitem_name=items[i].getAttribute('title');varitem_url='http://en.wikipedia.org/w/index.php?diff=cur&oldid=prev&title='+escape(item_name);a=document.createElement('a');a.setAttribute('href',item_url);a.appendChild(document.createTextNode(item_name));varli=document.createElement('li');li.appendChild(a);list.appendChild(li);}// Container divvardiv=document.createElement('div');div.setAttribute('id','p-recentchanges');div.className='portlet';varheading=document.createElement('h5');heading.appendChild(document.createTextNode('Recent Changes'));div.appendChild(heading);div.appendChild(link_div);// disable linkvarp=document.createElement('p');p.style.fontSize='x-small';p.style.margin='0px';p.style.textAlign='right';a=document.createElement('a');a.appendChild(document.createTextNode('disable this box'));a.onclick=rcp_disable_box;p.appendChild(a);link_div.appendChild(p);// now replace the divvarold_div=document.getElementById('p-recentchanges');varside_col=document.getElementById('column-one');if(old_div!=null){side_col.replaceChild(div,old_div);}else{varnode=document.getElementById('p-search');side_col.insertBefore(div,node);}// and do it again in 5 secssetTimeout("rcp_ajax_request()",rcp_refresh*1000);}functionrcp_disable_box(){rcp_enabled=false;rcp_draw_disabled_box();document.cookie="rcp_show_box=no; path=/";}functionrcp_enable_box(){rcp_enabled=true;document.cookie="rcp_show_box=yes; path=/";rcp_ajax_request();}functionrcp_draw_disabled_box(){// Container divvarlink_div=document.createElement('div');link_div.className='pBody';vardiv=document.createElement('div');div.setAttribute('id','p-recentchanges');div.className='portlet';varheading=document.createElement('h5');heading.appendChild(document.createTextNode('Recent Changes'));div.appendChild(heading);div.appendChild(link_div);// enable linkvarp=document.createElement('p');p.style.fontSize='x-small';p.style.margin='0px';vara=document.createElement('a');a.appendChild(document.createTextNode('enable this box'));a.onclick=rcp_enable_box;p.appendChild(a);link_div.appendChild(p);// now replace the divvarold_div=document.getElementById('p-recentchanges');varside_col=document.getElementById('column-one');if(old_div!=null){side_col.replaceChild(div,old_div);}else{varnode=document.getElementById('p-search');node.parentNode.insertBefore(div,node);}}