User:Lenore/autolink.js: Difference between revisions

Content deleted Content added
parsing ImportScript in code sections
Special:NewPages too; excluding URL with { or }; simplifying wlink regex (diffchange); +diffchange in tmp regex; excl tmp name with &
Line 47:
*/___location.href.indexOf('Speciale:ModificheCorrelate') != -1 || /*
*/___location.href.indexOf('Special:RecentChangesLinked') != -1 || /*
*/___location.href.indexOf('Speciale:PaginePiùRecenti') != -1 || /*
*/___location.href.indexOf('Special:NewPages') != -1 || /*
*/___location.href.indexOf('Speciale:Contributi') != -1 || /*
*/___location.href.indexOf('Special:Contributions') != -1;
Line 78 ⟶ 80:
var autolinkColor = ''; // Link color in history pages
 
autolinkRegexURLinWcodeWoLabel = /()\[{1}((?:https?|ftps?):\/\/[^\{\}\s]+?)\s*\]{1}()/g;
// External links in history pages, wikicode without label
 
autolinkRegexURLinWcodeWithLabel = /()\[{1}((?:https?|ftps?):\/\/[^\{\}\s]+)()\s+([^\]\n]+)\]{1}()/g;
// External links in history pages, wikicode with label (the URL will not be visible)
 
Line 88 ⟶ 90:
var autolinkColor = 'inherit'; // Link color in other pages
 
autolinkRegexURLinWcodeWoLabel = /(\[{1})((?:https?|ftps?):\/\/[^\{\}\s]+?)(\s*\]{1})/g;
// External links in other pages, wikicode without label
 
autolinkRegexURLinWcodeWithLabel = /(\[{1})(((?:https?|ftps?):\/\/[^\{\}\s]+))(\s+[^\]\n]+)(\]{1})/g;
// External links in other pages, wikicode with label
 
}
 
autolinkRegexURL = /([^>"\[]|[^\=]")((?:https?|ftps?):\/\/[^\{\}]+?)([\s\]\)\}'"]+)/g;
// External links (no wikicode)
 
autolinkRegexWlink = /\[{2}([^\[\]<>\n]*?)(\<span class\="diffchange"\>|)([^\[\]<>\n]*?)(\<\/span\>|)([^\[\]<>\n]*?)(|\|[^\n]*?)\]{2}/g;
// Wikilinks
 
autolinkRegexTemplate = /\{{2}([Ss][Uu][Bb][Ss][Tt]\:|[Mm][Ss][Gg]\:|[Mm][Ss][Gg][Nn][Ww]\:|)(\<span class\="diffchange"\>|)([^\{\}\:\&\|<>\n]+?)(\<\/span\>|)(\s*(?:(?:\:|\|)|\}{2}))/g;
// Templates
 
autolinkRegexInternalURL = /([^\=])('|")((?:\/?w\/index\.php\?|\/?wiki\/)[^\s\{\}]+?)\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
 
Line 129 ⟶ 131:
 
autolinkContent = autolinkContent.replace(autolinkRegexURL,
'$1<a class="autolink" style="color:' + autolinkColor + '" href="$2">$2</a>$3');
// Parse inactive external links (no wikicode)
 
autolinkContent = autolinkContent.replace(autolinkRegexWlink,
'[[<a class="autolink" style="color:' + autolinkColor + '" href="/wiki/$1$3$52">$1$2$3$4$5</a>$64]]');
// Make wikilink code into links
 
autolinkContent = autolinkContent.replace(autolinkRegexTemplate,
'{{<a class="autolink" style="color:' + autolinkColor + '" href="/wiki/Help:$1">$1</a><a class="autolink" style="color:' + autolinkColor + '" href="/wiki/Template:$23">$2$3$4</a>$35');
// Make template code into links