सदस्य:संतोष दहिवळ/vector.js/autolinker.js

विकिपीडिया, मुक्‍त ज्ञानकोशातून

नोंद: साठवून ठेवल्यानंतर बदल पहाण्यासाठी कदाचित तुमच्या ब्राऊजरच्या कॅचेला बायपास करावे लागेल.

  • फ़ायरफ़ॉक्स / सफ़ारी: धरुन ठेवा Shift टिचकी मारताना Reload, किंवा हे दाबताना Ctrl-F5 किंवा Ctrl-R (⌘-R मॅकवर)
  • गुगल क्रोम: दाबा Ctrl-Shift-R (⌘-Shift-R मॅकसाठी)
  • ओपेरा: कडे जा Menu → Settings (ओपेरा → पसंतीक्रम on a Mac) आणि मग गोपनियता आणि सुरक्षा → ब्राउजिंग डाटा काढून टाका → कॅचे छायाचित्रे आणि धारिणी.
/* <pre><nowiki> */

/* Autolink [[wikilinks]] and {{templates}} (especially useful for monobook.js and similar pages) */
/* See [[Wikipedia:WikiProject User scripts/Scripts/Autolink]] */
/* Shouldn't affect things *inside* HTML tags, either */

addOnloadHook(function () {
    // Get the HTML of just the main body of the page, not including textareas hopefully

    if (document.getElementById('wikiDiff')) {
        targetdiv = document.getElementById('wikiDiff');   // wikiDiff if it's there
    } else {

    if (document.getElementById('wikiPreview')) {
        targetdiv = document.getElementById('wikiPreview');  // wikiPreview if it's there
    } else

    if (document.getElementById('bodyContent')) {
        targetdiv = document.getElementById('bodyContent');  // bodyContent div for most pages
    } else
        return;
    }
    var 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
});

/* </nowiki></pre> */