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.
//<pre><nowiki>// Watchlist export/import ([[User:ais523/watchlistei.js]]), by [[User:ais523]].// To use this script, visit [[Special:Watchlist]] and follow the new links for 'import' or 'export'// there. The exported watchlist can be copy/pasted into the edit box for import, and is also legal// (but somewhat obfuscated) wikitext for use with [[Special:Recentchangeslinked]]. Doesn't work in// Internet Explorer, does work in Firefox 1, I haven't checked other browsers.// To install this script, the easiest way is to type {{subst:js|User:ais523/watchlistei.js}} at the// bottom of [[Special:Mypage/monobook.js]], and bypass your cache (Ctrl-F5 in Firefox for Windows).// Each line of an exported watchlist is in the form// *[[urlencodedpagename]]// Note that this feature is now part of the software, making this script redundant.if(navigator.userAgent.indexOf("MSIE")==-1)// fail gracefully in IE{// AJAXvarwleiwpajax;// From [[WP:US]] mainpage (wpajax renamed to wleiwpajax)wleiwpajax={download:function(bundle){// mandatory: bundle.url// optional: bundle.onSuccess (xmlhttprequest, bundle)// optional: bundle.onFailure (xmlhttprequest, bundle)// optional: bundle.otherStuff OK too, passed to onSuccess and onFailurevarx=window.XMLHttpRequest?newXMLHttpRequest():window.ActiveXObject?newActiveXObject("Microsoft.XMLHTTP"):false;if(x){x.onreadystatechange=function(){x.readyState==4&&wleiwpajax.downloadComplete(x,bundle);};x.open("HEAD",bundle.url,true);x.send(null);}returnx;},downloadComplete:function(x,bundle){x.status==200&&(bundle.onSuccess&&bundle.onSuccess(x,bundle)||true)||(bundle.onFailure&&bundle.onFailure(x,bundle)||alert(x.statusText));}};varwleiRunOnce=1;// Links to export and import$(function(){if(wgPageName=="Special:Watchlist"&&location.href.indexOf("list/")==-1&&wleiRunOnce){wleiRunOnce=0;vart=document.getElementById('bodyContent').getElementsByTagName('hr')[0];varn=document.createElement("p");t.parentNode.replaceChild(n,t);n.innerHTML="You can also <a href='http://en.wikipedia.org/wiki/Special:Watchlist/edit"+"?ais523wlei=export'>export</a> this watchlist or <a href='http://en.wikipedia.org/wiki/"+"Special:Watchlist/edit?ais523wlei=import'>import</a> pages from an exported watchlist.<hr/>";}});varwleiExRunOnce=1;// Exporting: producing the list$(function(){if(location.href.indexOf("Special:Watchlist/edit?ais523wlei=export")!=-1&&wleiExRunOnce){wleiExRunOnce=0;vara=document.getElementById('bodyContent').getElementsByTagName('input');varb=newArray();b[0]="<h2>Exported watchlist:</h2>\n<pre>";vari=0;while(i<a.length-1){b[i+1]="*[[:"+encodeURIComponent(a[i].value)+"]]";i++;}b[i+1]="</pre>";document.getElementById('bodyContent').innerHTML=b.join('\n');}});//Importing: textarea to input the watchlist$(function(){if(location.href.indexOf("Special:Watchlist/edit?ais523wlei=import")!=-1){document.getElementById('bodyContent').innerHTML="Watchlist to import:<br/><textarea id='watchlistImport' rows=20 cols=80></textarea><br/>\n"+"<a href='javascript:wleiImport()'>Import watchlist</a><br/>\n"+"Pages not yet processed: <span id='wlein'>0</span>, retrying: <span id='wleif'>0</span> "+"(total retries: <span id='wleir'>0</span>, 4 retries max per page allowed), "+"succeeded: <span id='wleis'>0</span>, failed: <span id='wleic'>0</span>.<br />\n"+"Return to <a href='http://en.wikipedia.org/wiki/Special:Watchlist'>watchlist</a>.\n<div id='faillist'></div>";}});functionwleiImport(){vara=document.getElementById('watchlistImport').value.split('\r').join('\n').split('\n');vari=a.length;while(i--){varm=a[i].match(/^\** *\[\[(.*)\]\] *$/);if(m!=undefined&&m[1]!=undefined&&m[1]!=""){watchPageUsingAJAX(m[1]);document.getElementById('wlein').innerHTML=1+newNumber(document.getElementById('wlein').innerHTML);}}}functionwleiSuccess(a,b){document.getElementById('wleis').innerHTML=1+newNumber(document.getElementById('wleis').innerHTML);if(b.isRetrying){document.getElementById('wleif').innerHTML=newNumber(document.getElementById('wleif').innerHTML)-1;}else{document.getElementById('wlein').innerHTML=newNumber(document.getElementById('wlein').innerHTML)-1;}}functionwleiFailure(a,b){if(!b.isRetrying){document.getElementById('wleif').innerHTML=1+newNumber(document.getElementById('wleif').innerHTML);document.getElementById('wlein').innerHTML=newNumber(document.getElementById('wlein').innerHTML)-1;}b.isRetrying++;if(b.isRetrying<5){document.getElementById('wleir').innerHTML=1+newNumber(document.getElementById('wleir').innerHTML);window.setTimeout(function(){wleiwpajax.download(b);},a.getResponseHeader('Retry-After')*1000);}else{document.getElementById('wleif').innerHTML=newNumber(document.getElementById('wleif').innerHTML)-1;document.getElementById('wleic').innerHTML=newNumber(document.getElementById('wleic').innerHTML)+1;if(document.getElementById('faillist').innerHTML=='')document.getElementById('faillist').innerHTML='Failed:';document.getElementById('faillist').innerHTML+='<br/>*[[<a href="'+b.url.split("&maxlag=5").join("")+'">'+b.urlencodedpagename+'<a>]]';}return1;}functionwatchPageUsingAJAX(urlencodedpagename){wleiwpajax.download({url:'http://en.wikipedia.org/w/index.php?title='+urlencodedpagename+'&action=watch&maxlag=5',onSuccess:wleiSuccess,onFailure:wleiFailure,isRetrying:0,urlencodedpagename:urlencodedpagename});}}//</nowiki></pre>//[[Category:Wikipedia scripts]]