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.
// Autolink [[wikilinks]], [external links] and {templates} (especially useful for monobook.js // and similar pages); adapted from [[Wikipedia:WikiProject User scripts/Scripts/Autolink]]/* ---------------------------------------------------------------------------------------------- */$(function(){varautolinkCronoSpecial=mw.config.get('wgCanonicalSpecialPageName')=="Recentchanges"||/* */mw.config.get('wgCanonicalSpecialPageName')=="Watchlist"||/* */mw.config.get('wgCanonicalSpecialPageName')=="Recentchangeslinked"||/* */mw.config.get('wgCanonicalSpecialPageName')=="Newpages"||/* */mw.config.get('wgCanonicalSpecialPageName')=="Log"||/* */mw.config.get('wgCanonicalSpecialPageName')=="Contributions";// Special crono pages where this script is enabledif((typeof(autolinkMySpecialPage)!="undefined"))autolinkCronoSpecial=autolinkCronoSpecial||mw.config.get('wgPageName')==autolinkMySpecialPage;if(mw.config.get('wgCanonicalNamespace')=="Special"&&!autolinkCronoSpecial){return;// Disabled in the other special pages}if(typeof(autolinkParseLink)=='undefined'){autolinkParseLink=true;// Parse links in all cases, even in diffs. To be disabled when wikEd is active}/* ---------------------------------------- Variables ------------------------------------------- */varautolinkDiff=___location.href.indexOf('diff=')!=-1;// It says if I'm in a diff pagevarautolinkCrono=(mw.config.get('wgAction')=='history'||autolinkCronoSpecial);// It says if I'm in a history pagevarautolinkEdit=($.inArray(mw.config.get('wgAction'),['edit','submit'])!==-1);// It says if I'm in an edit or submit pagevarautolinkColor;// links colorvarautolinkTargetDiv=[];if(autolinkDiff){// in diff pagesif(autolinkParseLink){// without wikEdautolinkTargetDiv[0]=$('.diff');autolinkTargetDiv[1]=$('.firstrevisionheader');autolinkColor='inherit';// not coloured links}else{// with wikEdautolinkTargetDiv[0]=$('.comment');autolinkColor='';// coloured links }}elseif(autolinkCrono||autolinkEdit){// in commentsautolinkTargetDiv[0]=$('.comment');autolinkColor='';// coloured links}else{// in code sectionsautolinkTargetDiv[0]=$('source');autolinkTargetDiv[1]=$('.javascript');autolinkTargetDiv[2]=$('.source-javascript');autolinkTargetDiv[3]=$('.css');autolinkTargetDiv[4]=$('.source-css');autolinkColor='';// coloured links}/* ------------------------------------------ Regex --------------------------------------------- */varautolinkRegexTl;varautolinkRegexURL;varautolinkRegexURLinWcodeWoLabel;varautolinkRegexSubstinWcodeWoLabel;varautolinkRegexURLinWcodeWithLabel;varautolinkRegexSubstinWcodeWithLabel;varautolinkRegexOtherPages;varautolinkRegexSubstOtherPages;varautolinkRegexTemplate;varautolinkRegexSubstTemplate;varautolinkRegexWlink1;varautolinkRegexSubstWlink1;varautolinkRegexWlink2;varautolinkRegexSubstWlink2;varautolinkRegexInternalURL;varautolinkRegexImportScript;varautolinkActivateHTML=false;/* ------------------------------------------------------------------------------------------ */autolinkRegexTl=/([^{]{{2}\s*[Tt]l\|)([^[\]{}|:<>\n]+)/g;// For {{tl}}autolinkRegexURL=/((?:[^"\[]|[^=]")(?:<span class="diffchange">)?)((?:https?|ftps?):\/\/[\w._\/\\~%\-+&#?!=()@:]+?)(?=(?:<\/span>)?[\s|)\]}'"])/g;// External links (no wikicode)// Regex for diffsautolinkRegexURLinWcodeWoLabel=/((?:[^\[]|^)\[\s*(?:<\/span>)?\s*(?:<span class="diffchange">)?\s*)((?:https?|ftps?):\/\/[\w._\/\\~%\-+&#?!=()@:]+)((?:<\/span>)?(?:<span class="diffchange">)?)([\w._\/\\~%\-+&#?!=()@:]*)((?:<\/span>)?(?:<span class="diffchange">)?)([\w._\/\\~%\-+&#?!=()@:]*)([^\]\n]*\])/gm;autolinkRegexSubstinWcodeWoLabel='$1<a class="external autolink" style="color:'+autolinkColor+'" href="$2$4$6">$2</a>$3<a class="external autolink" style="color:'+autolinkColor+'" href="$2$4$6">$4</a>$5<a class="external autolink" style="color:'+autolinkColor+'" href="$2$4$6">$6</a>$7';// External links in diff pages, wikicode without labelautolinkRegexURLinWcodeWithLabel=autolinkRegexURLinWcodeWoLabel;autolinkRegexSubstinWcodeWithLabel=autolinkRegexSubstinWcodeWoLabel;// External links in diff pages, wikicode with labelautolinkRegexOtherPages=/((?:[^{]|^)\{{2}\s*(?:<\/span>)?\s*(?:<span class="diffchange">)?\s*(?:(?:[Ss][Uu][Bb][Ss][Tt]|[Mm][Ss][Gg]|[Mm][Ss][Gg][Nn][Ww])\s*:)?\s*(?:<\/span>)?\s*(?:<span class="diffchange">)?\s*)((?:[Dd]iscussion[ei] ?)?\s*(?:[Ss]peciale?|[Ww](?:ikipedia|P)|[Tt]emplate|[Uu](?:ser|tente)|[Pp]ortale?|[Pp]rogetto)?\s*(?: ?[Tt]alk)?\s*:[^[\]{}|:<>\n]+)((?:<\/span>)?(?:<span class="diffchange">)?)([^[\]{}|:<>\n]*)((?:<\/span>)?(?:<span class="diffchange">)?)([^[\]{}|:<>\n]*)(\||}{2})/gm;autolinkRegexSubstOtherPages='$1<a class="autolink" style="color:'+autolinkColor+'" href="/wiki/$2$4$6">$2</a>$3<a class="autolink" style="color:'+autolinkColor+'" href="/wiki/$2$4$6">$4</a>$5<a class="autolink" style="color:'+autolinkColor+'" href="/wiki/$2$4$6">$6</a>$7';// Other pages included in diff pagesautolinkRegexTemplate=/((?:[^{]|^)\{{2}\s*(?:<\/span>)?\s*(?:<span class="diffchange">)?\s*(?:(?:[Ss][Uu][Bb][Ss][Tt]|[Mm][Ss][Gg]|[Mm][Ss][Gg][Nn][Ww])\s*:)?\s*(?:<\/span>)?\s*(?:<span class="diffchange">)?)([^[\]{}|:<>\n]+)((?:<\/span>)?(?:<span class="diffchange">)?)([^[\]{}|:<>\n]*)((?:<\/span>)?(?:<span class="diffchange">)?)([^[\]{}|:<>\n]*)(\||}{2}|:)/gm;autolinkRegexSubstTemplate='$1<a class="autolink" style="color:'+autolinkColor+'" href="/wiki/Template:$2$4$6">$2</a>$3<a class="autolink" style="color:'+autolinkColor+'" href="/wiki/Template:$2$4$6">$4</a>$5<a class="autolink" style="color:'+autolinkColor+'" href="/wiki/Template:$2$4$6">$6</a>$7';// Templates in diff pages autolinkRegexWlink1=/(\[{2}\s*(?:<\/span>)?\s*(?:<span class="diffchange">)?\s*)([^[\]{}|<>\n]+)((?:<\/span>)?(?:<span class="diffchange">)?)([^[\]{}|<>\n]*)((?:<\/span>)?(?:<span class="diffchange">)?)([^[\]{}|<>\n]*)((?:[^\]\n]|\][^\]])*\]{2})/g;autolinkRegexSubstWlink1='$1<a class="autolink" style="color:'+autolinkColor+'" href="/wiki/$2$4$6">$2</a>$3<a class="autolink" style="color:'+autolinkColor+'" href="/wiki/$2$4$6">$4</a>$5<a class="autolink" style="color:'+autolinkColor+'" href="/wiki/$2$4$6">$6</a>$7';// Wikilinks in diff pagesautolinkRegexWlink2=autolinkRegexWlink1;autolinkRegexSubstWlink2=autolinkRegexSubstWlink1;// Regex for comments or code sectionsif(!autolinkDiff||(autolinkDiff&&!autolinkParseLink)){autolinkRegexURLinWcodeWoLabel=/([^\[]|^)\[\s*((?:https?|ftps?):\/\/[\w._\/\\~%\-+&#?!=()@:]+)\s*\]/gm;autolinkRegexSubstinWcodeWoLabel='$1<a class="external autolink" style="color:'+autolinkColor+'" href="$2">$2</a>';// External links in comments or code sections, wikicode without labelautolinkRegexURLinWcodeWithLabel=/([^\[]|^)\[\s*((?:https?|ftps?):\/\/[\w._\/\\~%\-+&#?!=()@:]+)\s+([^\n]+?)\s*\]/gm;autolinkRegexSubstinWcodeWithLabel='$1<a class="external autolink" style="color:'+autolinkColor+'" href="$2">$3</a>';// External links in comments or code sections, wikicode with label (the URL will not be visible)autolinkRegexOtherPages=/((?:[^{]|^)\{{2}\s*(?:(?:[Ss][Uu][Bb][Ss][Tt]|[Mm][Ss][Gg]|[Mm][Ss][Gg][Nn][Ww])\s*:)?\s*)((?:[Dd]iscussion[ei] ?)?\s*(?:[Ss]peciale?|[Ww](?:ikipedia|P)|[Tt]emplate|[Uu](?:ser|tente)|[Pp]ortale?|[Pp]rogetto)?\s*(?: ?[Tt]alk)?\s*:[^[\]{}|:<>\n]+)(\||}{2})/gm;autolinkRegexSubstOtherPages='$1<a class="autolink" style="color:'+autolinkColor+'" href="/wiki/$2">$2</a>$3';// Other pages included in comments or code sectionsautolinkRegexTemplate=/((?:[^{]|^)\{{2}\s*(?:(?:[Ss][Uu][Bb][Ss][Tt]|[Mm][Ss][Gg]|[Mm][Ss][Gg][Nn][Ww])\s*:)?\s*)([^[\]{}|:<>\n]+)(\||}{2}|:)/gm;autolinkRegexSubstTemplate='$1<a class="autolink" style="color:'+autolinkColor+'" href="/wiki/Template:$2">$2</a>$3';// Templates in comments or code sections autolinkRegexWlink1=/\[{2}\s*([^[\]{}|<>\n]+?)\s*\|\s*(.+?)\s*\]{2}/g;autolinkRegexSubstWlink1='<a class="autolink" style="color:'+autolinkColor+'" href="/wiki/$1">$2</a>';// Wikilinks in code sections, with labelautolinkRegexWlink2=/\[{2}\s*([^[\]{}|<>\n]+?)\s*\|?\s*\]{2}/g;autolinkRegexSubstWlink2='<a class="autolink" style="color:'+autolinkColor+'" href="/wiki/$1">$1</a>';// Wikilinks in code sections, without labelautolinkActivateHTML=true;// Activate some HTML (inline) and wikicode for bold and italic}autolinkRegexInternalURL=/([^=])('|"|\s)((?:\/?w\/index\.php\?|\/?wiki\/)[\w._\/\\~%\-+&#?!=()@:]+)\2/g;// External links (no wikicode, under wgServer)autolinkRegexImportScript=/([Ii]mport[Ss]cript(?:<span class="br0">)?\((?:<\/span><span class="st0">)?)('|")([^[\]{}|<>\n]+?)(\2(?:<\/span><span class="br0">)?\)(?:<\/span>)?)/g;// ImportScript/* ---------------------------------------------------------------------------------------------- */for(i=0;i<autolinkTargetDiv.length;i++){for(j=0;j<autolinkTargetDiv[i].length;j++){varautolinkContent=autolinkTargetDiv[i][j].innerHTML;autolinkContent=autolinkContent.replace(/</g,'­<­');autolinkContent=autolinkContent.replace(/>/g,'­>­');// &lt; to &shy;<&shy; and &gt; to &shy;>&shy; (&shy; is a marker)autolinkContent=autolinkContent.replace(/&/g,'&');// &amp; to &/* ----------------------------------------------------------------------------------- */autolinkContent=autolinkContent.replace(autolinkRegexTl,'$1<a class="autolink" style="color:'+autolinkColor+'" href="/wiki/Template:$2">$2</a>');// For {{tl}}: make his argument into linkautolinkContent=autolinkContent.replace(autolinkRegexURL,'$1<a class="external autolink" style="color:'+autolinkColor+'" href="$2">$2</a>');// Parse inactive external links (no wikicode)autolinkContent=autolinkContent.replace(autolinkRegexURLinWcodeWoLabel,autolinkRegexSubstinWcodeWoLabel);// Make external links in wikicode without label into linksautolinkContent=autolinkContent.replace(autolinkRegexURLinWcodeWithLabel,autolinkRegexSubstinWcodeWithLabel);// Make external links in wikicode with label into linksautolinkContent=autolinkContent.replace(autolinkRegexOtherPages,autolinkRegexSubstOtherPages);// Make other pages included code into linksautolinkContent=autolinkContent.replace(autolinkRegexTemplate,autolinkRegexSubstTemplate);autolinkContent=autolinkContent.replace(/href\="\/wiki\/Template\:#/g,'href="/wiki/Help:');// Make template code into linksautolinkContent=autolinkContent.replace(autolinkRegexWlink1,autolinkRegexSubstWlink1);autolinkContent=autolinkContent.replace(autolinkRegexWlink2,autolinkRegexSubstWlink2);// Make wikilink code into linksautolinkContent=autolinkContent.replace(autolinkRegexInternalURL,'$1$2<a class="external autolink" style="color:'+autolinkColor+'" href="'+mw.config.get('wgServer')+'$3">$3</a>$2');// Parse inactive external links (no wikicode, under wgServer)autolinkContent=autolinkContent.replace(autolinkRegexImportScript,'$1$2<a class="autolink" style="color:'+autolinkColor+'" href="/wiki/$3">$3</a>$4');// Parse ImportScript/* ----------------------------------------------------------------------------------- */autolinkContent=autolinkContent.replace(/­<­/g,'<');autolinkContent=autolinkContent.replace(/­>­/g,'>');// &shy;<&shy; to &lt; and &shy;>&shy; to &gt; (revert)if(autolinkActivateHTML){autolinkContent=autolinkContent.replace(/<(span|b|i|strong|small|tt|del|s|u|sub|sup)>(.*?)<\/(\1)>/g,'<$1>$2</$3>');autolinkContent=autolinkContent.replace(/([^']|^)'{3}(.+?)'{3}([^']|$)/gm,'$1<b>$2</b>$3');autolinkContent=autolinkContent.replace(/([^']|^)'{2}(.+?)'{2}([^']|$)/gm,'$1<i>$2</i>$3');if(autolinkCrono||autolinkEdit)autolinkContent=autolinkContent.replace(/<i>(.*?)<\/i>/g,'<span title="italic" style="border: 1px solid silver; padding: 2px;">$1</span>');// I'm in a comment field (italic)}if(autolinkDiff&&autolinkParseLink){autolinkContent=autolinkContent.replace(/<a [^>]+><\/a>/g,'');// CleanautolinkContent=autolinkContent.replace(/([^\[]|^)\[\s*(<a [^>]+>)(?:https?|ftps?):\/\/[\w._\/\\~%\-+&#?!=()@:]+(<\/a>)\s+([^\]\n]+)\]/gm,'$1$2$4$3');autolinkContent=autolinkContent.replace(/([^\[]|^)\[\s*(<a [^>]+>)((?:https?|ftps?):\/\/[\w._\/\\~%\-+&#?!=()@:]+)(<\/a>)\s*\]/gm,'$1$2$3$4');}autolinkTargetDiv[i][j].innerHTML=autolinkContent;// Write it back}}});// [[Category:Wikipedia scripts|Autolink]]