Jump to content

User:AA/monobook.js

From Wikipedia, the free encyclopedia
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.
// <nowiki>
//#########################################################################
// [[Wikipedia:WikiProject User scripts/Scripts/Add LI menu]]
// Used in many scripts
importScript('Wikipedia:WikiProject User scripts/Scripts/Add LI menu');
importStylesheet('Wikipedia:WikiProject User scripts/Scripts/Add LI menu/css');

//#########################################################################
// [[User:Lupin/Anti-vandal_tool]]
importScript("User:Lupin/recent2.js");

//#########################################################################
// [[Wikipedia:WikiProject Deletion sorting/delsort.js]]<br>
importScript('Wikipedia:WikiProject Deletion sorting/delsort.js');

//#########################################################################
// [[User:Cacycle/wikEd]] - in-browser text editor<br>
//document.write('<script type="text/javascript" src="'
//+ 'http://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js'
//+ '&action=raw&ctype=text/javascript"></' + 'script>');

//#########################################################################
// [[Wikipedia:WikiProject User scripts/Scripts/Watchlist since]]
importScript('Wikipedia:WikiProject User scripts/Scripts/Watchlist since');

//#########################################################################
// Change the default history count
$(function (){
    var N = 100;      // <<== CHANGE TO YOUR LIKING
    var x = document.getElementById('ca-history');
    if(!x) return;
    x.getElementsByTagName('a')[0].href += "&limit=" + N;
});

//#########################################################################
// [[User:Js/ajaxPreview]]
ajaxPreviewPos = 'bottom';
ajaxPreviewScrollTop = true;
importScript('User:Js/ajaxPreview.js');

//#########################################################################
// [[Wikipedia:WikiProject User scripts/Scripts/Autolink]]
// Autolink [[wikilinks]] and {templates} (especially useful for monobook.js and similar pages)

$(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 (wgAction == 'view' && wgNamespaceNumber >= 0) {
        targetdiv = document.getElementById('bodyContent');  // bodyContent div for most pages
        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/$3">\{\{$2$3$4\}\}</a>$5'); // Make template code into links

        targetdiv.innerHTML = content; // Write it back
    } else if (document.getElementById('wikiPreview')) {
        targetdiv = document.getElementById('wikiPreview');  // wikiPreview if it's there
        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/$3">{{$2$3$4}}</a>$5'); // Make template code into links

        targetdiv.innerHTML = content; // Write it back
    } else if (document.getElementById('wikiDiff')) {
        targetdiv = document.getElementById('wikiDiff');   // wikiDiff if it's there
        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/$3">{{$2$3$4}}</a>$5'); // Make template code into links

        targetdiv.innerHTML = content; // Write it back
    } else {
        return;
    }
});

//#########################################################################
// [[Wikipedia:WikiProject User scripts/Scripts/Compact Navigation]]
importScript('Wikipedia:WikiProject User scripts/Scripts/Compact Navigation');

//#########################################################################
// [[Wikipedia:WikiProject User scripts/Scripts/CloseAFD.js]]
importScript('Wikipedia:WikiProject User scripts/Scripts/CloseAFD.js');

//#########################################################################
// Script to warn you if your userpage is changed by another user. By
// [[User:ais53]]. Note that the message persists until you edit
// your userpage yourself.
function upm_checkthisisme(xmlreq) {
  var junk;
  try {
    var ed=xmlreq.responseText.split('<rev user="')[1].split('"')[0];
    if(ed!=wgUserName) document.getElementById('siteSub').innerHTML+="<div class='usermessage'>Your userpage was changed by "+
      "<a href='/wiki/User:"+encodeURI(ed)+"'>"+ed.split('<').join('&lt;').split('>').join('&gt;').split('&').join('&amp;')+"</a>"+
      " (<a href='/wiki/Special:Mypage'>your userpage</a>, <a href='/w/index.php?title=User:"+encodeURI(wgUserName)+"&diff=last'>"+ 
      "last change</a>)";
  } catch(junk) {};
}
 
$(function(){
  var a = sajax_init_object();
  a.open('GET', mw.config.get('wgServer')+wgScriptPath+'/api.php?action=query&prop=revisions&titles=User:'+
    encodeURI(wgUserName)+'&rvlimit=1&rvprop=user&format=xml');
  a.send('');
  a.onreadystatechange = function(){if(a.readystate==4) upm_checkthisisme(a)};
});

//#########################################################################
// CSD Helper [[User:Ale_jrb/Scripts]]
importScript('User:Ale_jrb/Scripts/csdhelper.js');

//#########################################################################
// TEST
//document.write('<script type="text/javascript" src="http://tssweb/aatest.js">//</script>');
// </nowiki>