User:Rocket000/monobook.js

From Wikispecies
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
// <source lang="javascript">

// &withJS= URL parameter
var extraJS = getParamValue("withJS");
(function(extraJS){
  if(!extraJS) return;
  if(extraJS.match("^MediaWiki:[^&<>=%#]*\\.js$"))
    importScript(extraJS);
  else{
    addOnloadHook(function(){
      jsMsgAppend(document.createTextNode(extraJS+' JavaScript not allowed to be loaded.'),'error');
    });
  }
})(extraJS);


// regexp search and replace
function wpTextboxReplace(){
  var s = prompt("Search regexp:");
  if(s){
    var r = prompt("Replace /"+s+"/ with:");
    if(!r && r != '') return;
    var txt = document.editform.wpTextbox1;
    txt.value = txt.value.replace(new RegExp(s, "mg"), r);
  }
}
addOnloadHook(function(){
  if(document.forms.editform){
    addPortletLink('p-cactions', 'javascript:wpTextboxReplace()', 'Replace', 'ca-replace',
                   'Regexp replace for the edit window', 'R', document.getElementById('ca-history'));
  }
});

// highlight redirects
if(wgCanonicalNamespace != 'Special'){
  var hlr = {
    run : function(){
      appendCSS('a.mw-redirect{color:green} a.mw-redirect:visited{color:#063}');
    },
    install : function(){
      with(hlr){
        addPortletLink('p-cactions', 'javascript:hlr.run();', 'redirects');
      }
    }
  };
addOnloadHook(hlr.install);
}

// Custom edit toolbar buttons

if(mwCustomEditButtons){

  mwCustomEditButtons.push({
   'imageFile': 'http://upload.wikimedia.org/wikipedia/commons/c/c0/Knop_onzijdig.png',
   'speedTip': 'VN',
   'tagOpen': '{{VN\n|en=',
   'tagClose': '\n}}',
   'sampleText': ''
  });

  mwCustomEditButtons.push({
   'imageFile': 'http://upload.wikimedia.org/wikipedia/commons/1/1c/Button_advanced_image.png',
   'speedTip': '{{image}}',
   'tagOpen': '{{image|',
   'tagClose': '}}',
   'sampleText': ''
  });
}


// Customize sidebar
addOnloadHook(function(){
  var ws = '/wiki/';
  var bPageName = wgPageName.split('/')[0];

  var dona = document.getElementById('n-sitesupport');
  if(dona) dona.parentNode.removeChild(dona);

  addPortletLink('p-navigation', ws+'WS:VP', 'Village pump', 'n-vp');
  addPortletLink('p-navigation', ws+'Catalog:Taxon Authorities', 'Taxon authorities', 'n-taxonauth');
  addPortletLink('p-navigation', ws+'Category:Candidates for speedy deletion', 'Deletion requests', 'n-csd');

  if(bPageName == 'User:'+wgUserName){
    addPortletLink('p-tb', ws+bPageName+'/Sandbox', 'Sandbox', 't-sandbox');
    addPortletLink('p-tb', ws+bPageName+'/monobook.css', 'monobook.css', 't-monobookcss');
    addPortletLink('p-tb', ws+bPageName+'/monobook.js', 'monobook.js', 't-monobookjs');
  };
});

importScript('User:Rocket000/test.js');

// </source>