Jump to content
Wikipedia The Free Encyclopedia

Wikipedia:WikiProject User scripts/Scripts/Autolink

From Wikipedia, the free encyclopedia

//

// Autolink [[wikilinks]] and {{templates}} (especially useful for monobook.js and similar pages)
addOnloadHook(function () {
 // Get the HTML of just the main body of the page, not including textareas hopefully
 if (location.href.indexOf('&action=history') != -1) {
 return; //The history page crashes when this script is used
 } else
 if (document.title.indexOf("Editing ") != 0 && document.title.indexOf("Template:") != 0) {
 targetdiv = document.getElementById('bodyContent'); // bodyContent div for most pages
 } else 
 if (document.getElementById('wikiPreview')) {
 targetdiv = document.getElementById('wikiPreview'); // wikiPreview if it's there
 } else
 if (document.getElementById('wikiDiff')) {
 targetdiv = document.getElementById('wikiDiff'); // wikiDiff if it's there
 } else {
 return;
 }
 content = targetdiv.innerHTML;
 content = content.replace(/([^\[])\[{2}([^\[\]\|\<\>\n]*)([^\[\]\<\>\n]*?)?\]{2}([^\]])/g, '1ドル<a class="autolink" href="/wiki/2ドル">[[2ドル3ドル]]</a>4ドル'); // Make wikilink code into links
 content = content.replace(/([^\{])\{{2}(subst\:|msg\:)?([^\{\}\|\<\>\n]*)([^\{\}\<\>\n]*?)?\}{2}([^\}])/g, '1ドル<a class="autolink" href="/wiki/Template:3ドル">{{2ドル3ドル4ドル}}</a>5ドル'); // Make template code into links
 targetdiv.innerHTML = content; // Write it back
});
//

AltStyle によって変換されたページ (->オリジナル) /