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.
/** Pages Created -- finds all the pages created by a user* see [[User:Jfmantis/pagesCreated]]*/(function(){/** create <li> list item for one article* right now, just a link to the page & the date*/functionmakeCreatedPageItem(contrib){varitem=document.createElement("li");varlink=document.createElement("a");link.href=mw.util.getUrl(contrib.title);link.innerHTML=contrib.title;item.appendChild(link);item.innerHTML+=" . . "+newDate(contrib.timestamp).toDateString();returnitem;}/** looks through all of a user's non-minor namespace 0 edits,* looking for edits tagged as "new"** the arguments all in one object so that it can be expanded* in the future without having to add a bunch more parameters*/functionfindPagesCreated(bundle){bundle.api.get({action:"query",rawcontinue:'',list:"usercontribs",ucuser:bundle.user,ucstart:bundle.start,ucprop:"flags|title|timestamp",ucshow:"!minor",uclimit:500,ucnamespace:0}).done(function(data){$.each(data.query.usercontribs,function(index,contrib){if(contrib.new!=undefined){bundle.list.appendChild(makeCreatedPageItem(contrib));bundle.count++;}});if(data["query-continue"]){// more contributionsbundle.start=data["query-continue"].usercontribs.ucstartsetTimeout(function(){findPagesCreated(bundle);},3000);}else{// done$("#pc-status")[0].innerHTML="<br />"+bundle.user+" has created "+bundle.count+" articles";}}).fail(function(error){alert(error);});}/** change title, clear content area, etc.*/functionsetupPagesCreated(user){// set new titlemw.util.$content.find("#firstHeading")[0].innerHTML="Pages created by "+user;// status bar (text + waiting gif)varstatus=document.createElement("span");status.id="pc-status";status.innerHTML="<br />Fetching user data...";// heading for resultsvarheading=document.createElement("h3");heading.innerHTML="Articles";// list of resultsvararticles=document.createElement("ul");articles.id="pc-articles";varbody=mw.util.$content.find("#bodyContent")[0];body.innerHTML="";body.appendChild(status);body.appendChild(heading);body.appendChild(articles);varapi=newmw.Api();api.get({action:"query",list:"users",ususers:user,usprop:"editcount"}).done(function(data){// 500 results per request, 1 request every 3 secondsvarcount=data.query.users[0].editcount;status.innerHTML="<br />User has "+count+" edits, this should take less than ";status.innerHTML+=(3*Math.round(count/500))+" seconds ";varwaitgif=document.createElement("img");waitgif.src="https://upload.wikimedia.org/wikipedia/commons/4/42/Loading.gif";status.appendChild(waitgif);findPagesCreated({"api":api,"user":user,"list":articles,"start":"","count":0});}).fail(function(error){alert(error);});returnfalse;}mw.loader.using("mediawiki.util",function(){// add portlet when page is User or User_talk, but not on subpagesif((mw.config.get('wgNamespaceNumber')==2||mw.config.get('wgNamespaceNumber')==3)&&(mw.config.get('wgTitle').indexOf("/")==-1)){if(mw.util.getParamValue("pagesCreated")){setupPagesCreated(mw.config.get('wgTitle'));}else{mw.util.addPortletLink("p-tb",document.___location.toString()+"?pagesCreated=true","Pages created","pc-pages","Get a list of all pages created by this user");}}});})();