Jump to content

User:SoledadKabocha/markBlockedPlus-portable.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.
function defaultPref( cfig, dflt ) {
  return ( typeof cfig == typeof dflt ? cfig : dflt );
}
 
function markBlocked( ) {
    mw.util.jsMessage(
        'This version of markBlockedPlus-portable.js has been deprecated. ' +
        'Please use <a href="https://en.wikipedia.org/wiki/User:SoledadKabocha/markBlockedPlus.js">' +
        'the original markBlockedPlus</a> instead for now.'
    );
}

//start on some pages
var zzAction = mw.config.get( 'wgAction' );
switch( zzAction ){
 case 'edit':
 case 'submit':
   if( !window.mbEnableWhenEditing ) break
 case 'purge':
   //shouldn't happen on recent MW; action=purge should redirect (or prompt for confirmation?) rather than showing page content
   //just give up
   break;
 case 'view':
   if( mw.config.get( 'wgNamespaceNumber' ) === 0 && !( window.mbEnableOnMainspaceDiff === true && document.URL.indexOf( 'diff=' ) != -1 ) ) break
   //otherwise continue with default
 default: //'history', etc.
  $(function(){
     if( window.mbNoAutoStart === true )
       mw.util.addPortletLink(defaultPref( window.mbOnDemandLinkLoc, 'p-cactions' ), 'javascript:markBlocked()', defaultPref( window.mbOnDemandLinkText, 'XX' ), 'ca-showblocks')
     else
       markBlocked()
  })
}