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.
// I take no credit for any of the code on this page.// The original code was copied from User:TheJosh/Scripts/NewPagePatrol.js // User:Thingg tweaked the code so that the newpage patrol box showed up below the search box, // because it was annoying to have to scroll down to search if I wanted to do something else // while keeping an eye on the newpage log. // After the position of the search box was changed, I kept this because I liked where the // newpage thingy shows up on my display, which is 1280x800px. varnpp_http;varnpp_enabled;varnpp_num_pages;varnpp_refresh;varnpp_num_idle_req;varnpp_curr_idle_req;// This part here is customizable. Read TheJosh's documentation if you want to change somethingnpp_enabled=false;npp_num_pages=50;npp_refresh=5;npp_num_idle_req=60;varnpp_str_no_ajax="There seems to be a problem using the NewPagePatrol script. Your browser is not supported. God Bless!";varnpp_str_box_title="New pages";varnpp_str_box_title_updating="New pages (updating)";varnpp_str_box_title_failed="New pages (update failed)";varnpp_str_enable="enable this box";varnpp_str_disable="disable this box";addOnloadHook(npp_init);/* initalise */functionnpp_init(){// allow user settings throughif(npp_enabled==null){npp_enabled=false;}if(npp_num_pages==null){npp_num_pages=10;}if(npp_refresh==null){npp_refresh=5;}if(npp_num_idle_req==null){npp_num_idle_req=60;}// A few limits to be nice to the serversif(npp_num_pages>50){npp_num_pages=50;}if(npp_num_pages<1){npp_num_pages=1;}if(npp_refresh<2){npp_refresh=2;}if(npp_num_idle_req>1000){npp_num_idle_req=1000;}if(npp_num_idle_req<5){npp_num_idle_req=5;}// get our cookieif(document.cookie.length>0){varc_start=document.cookie.indexOf("npp_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"){npp_enabled=true;}else{npp_enabled=false;}}}// Either make a request or show nothingnpp_curr_idle_req=0;if(npp_enabled==true){npp_ajax_request();}else{npp_draw_disabled_box();}}/* init ajax */functionnpp_create_request(){try{npp_http=newXMLHttpRequest();}catch(e){try{npp_http=newActiveXObject("Msxml2.XMLHTTP");}catch(e){try{npp_http=newActiveXObject("Microsoft.XMLHTTP");}catch(e){returnfalse;}}}npp_http.onreadystatechange=function(){if(npp_http.readyState==4)npp_ajax_response();}returntrue;}/* make a request */functionnpp_ajax_request(){// if we have done too many requests, disable the boxnpp_curr_idle_req++;if(npp_curr_idle_req>npp_num_idle_req){npp_disable_box();}// check we are enabledif(npp_enabled==false)return;// firstly, inform the uservarcur_box=document.getElementById('p-newpages');if(cur_box!=null){cur_box.firstChild.firstChild.data=npp_str_box_title_updating;}if(npp_create_request()==false){if(cur_box!=null){cur_box.firstChild.firstChild.data=npp_str_box_title_failed;}else{alert(npp_str_no_ajax);}}// Then make the requestnpp_http.open("GET","/w/api.php?action=query&format=xml&list=recentchanges&rcshow=!bot|!redirect&rctype=new&rcnamespace=0&rcprop=title|timestamp|ids|patrolled&rclimit="+npp_num_pages,true);npp_http.send(null);}/* we have received a response */functionnpp_ajax_response(){varitems=npp_http.responseXML.getElementsByTagName('rc');// create the div that holds all the newpage 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');varrcid=items[i].getAttribute('rcid');varpatrolled=items[i].getAttribute('patrolled')!=null;item_name=item_name.replace(/&/,"%26");varitem_url='http://en.wikipedia.org/w/index.php?title='+item_name+'&rcid='+rcid+'&redirect=no';a=document.createElement('a');a.setAttribute('href',item_url);a.appendChild(document.createTextNode(item_name));varli=document.createElement('li');li.appendChild(a);if(!patrolled){li.setAttribute('class','not-patrolled');}list.appendChild(li);}// Container divvardiv=document.createElement('div');div.setAttribute('id','p-newpages');div.className='portlet';varheading=document.createElement('h5');heading.appendChild(document.createTextNode(npp_str_box_title));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(npp_str_disable));a.onclick=npp_disable_box;p.appendChild(a);link_div.appendChild(p);// now replace the divvarold_div=document.getElementById('p-newpages');varside_col=document.getElementById('column-one');if(old_div!=null){side_col.replaceChild(div,old_div);}else{varnode=document.getElementById('p-tb');side_col.insertBefore(div,node);}// and do it again in 5 secssetTimeout("npp_ajax_request()",npp_refresh*1000);}functionnpp_disable_box(){npp_enabled=false;npp_draw_disabled_box();document.cookie="npp_show_box=no; path=/";}functionnpp_enable_box(){npp_enabled=true;npp_curr_idle_req=0;document.cookie="npp_show_box=yes; path=/";npp_ajax_request();}functionnpp_draw_disabled_box(){// Container divvarlink_div=document.createElement('div');link_div.className='pBody';vardiv=document.createElement('div');div.setAttribute('id','p-newpages');div.className='portlet';varheading=document.createElement('h5');heading.appendChild(document.createTextNode(npp_str_box_title));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(npp_str_enable));a.onclick=npp_enable_box;p.appendChild(a);link_div.appendChild(p);// now replace the divvarold_div=document.getElementById('p-newpages');varside_col=document.getElementById('column-one');if(side_col&&old_div!=null){side_col.replaceChild(div,old_div);}elseif(side_col){varnode=document.getElementById('p-tb');side_col.insertBefore(div,node);}}