Jump to content

User:Huntster/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.
  // Admin name highlighter; [[User:Theopolisme/Scripts/adminhighlighter.js]]
mw.loader.load('/w/index.php?title=User:Theopolisme/Scripts/adminhighlighter.js&action=raw&ctype=text/javascript');

  // Cactions drop down menus; [[User:Haza-w/Drop-down menus]]
mw.loader.load('/w/index.php?action=raw&ctype=text/javascript&title=User:Haza-w/cactions.js');

//Ohconfucius tools
  // Date formatter; [[User:Ohconfucius/script/MOSNUM dates.js]]
mw.loader.load('/w/index.php?title=User:Ohconfucius/script/MOSNUM dates.js&action=raw&ctype=text/javascript');
  // General formatting fixes; [[User:Ebrahames/Advisor]]
mw.loader.load('/w/index.php?title=User:Ebrahames/Advisor.js&action=raw&ctype=text/javascript');
  // Add Engvar script; [[User:Ohconfucius/script/EngvarB.js]]
mw.loader.load('/w/index.php?title=User:Ohconfucius/script/EngvarB.js&action=raw&ctype=text/javascript');
  // Add Engvar script; [[User:IceWelder/USEnglish.js]]
//mw.loader.load('/w/index.php?title=User:IceWelder/USEnglish.js&action=raw&ctype=text/javascript');
  // Delink common terms; [[User:Ohconfucius/script/Common Terms.js]]
mw.loader.load('/w/index.php?title=User:Ohconfucius/script/Common_Terms.js&action=raw&ctype=text/javascript');
  // Citation formatting; [[User:Ohconfucius/script/Sources.js]]
mw.loader.load('/w/index.php?title=User:Ohconfucius/script/Sources.js&action=raw&ctype=text/javascript');

  // Cat-a-lot for en.wiki; [[User:קיפודנחש/cat-a-lot.js]]
mw.loader.load('/w/index.php?title=User:קיפודנחש/cat-a-lot.js&action=raw&ctype=text/javascript');

  // References Segregator and LDR tool [[User:PleaseStand/segregate-refs]]
var SegregateRefsJsAllowConversion = true;
mw.loader.load('/w/index.php?title=User:PleaseStand/segregate-refs.js&action=raw&ctype=text/javascript');

  // AutoED script; [[Wikipedia:AutoEd]]
mw.loader.load('/w/index.php?title=Wikipedia:AutoEd/complete.js&action=raw&ctype=text/javascript');

  // Own name highlighter; [[User:Ais523/highlightmyname.js]]
mw.loader.load('/w/index.php?title=User:Huntster/monobook.js/highlightmyname.js&action=raw&ctype=text/javascript');

  // Format citation layout; [[User:Waldir/formatcitations.js]]
mw.loader.load('/w/index.php?title=User:Huntster/monobook.js/formatcitations.js&action=raw&ctype=text/javascript');

  // Highlight duplicate links; [[User:Ucucha/duplinks]]
mw.loader.load('/w/index.php?title=User:Ucucha/duplinks.js&action=raw&ctype=text/javascript');

  // AJAX unwatch; [[User:Js/watchlist.js]]
mw.loader.load('/w/index.php?title=User:Js/watchlist.js&action=raw&ctype=text/javascript');

  // Formatting advisor by Cameltrader [[User:Cameltrader/Advisor.js/Description]]
mw.loader.load('/w/index.php?title=User:Cameltrader/Advisor.js&action=raw&ctype=text/javascript');

// [[User:Caorongjin/wordcount]]
mw.loader.load('/w/index.php?title=User:Caorongjin/wordcount.js&action=raw&ctype=text/javascript');

mw.loader.load('/w/index.php?title=User:Anomie/util.js&action=raw&ctype=text/javascript');
  // Highlight redirects; [[User:Anomie/linkclassifier.js]]
mw.loader.load('/w/index.php?title=User:Anomie/linkclassifier.js&action=raw&ctype=text/javascript');

function setupPortletLinks() {
  // Button to access page hit stats
mw.util.addPortletLink('p-cactions', 'https://tools.wmflabs.org/pageviews/?project=en.wiki.x.io&platform=all-access&agent=user&range=latest-90&pages='+ encodeURIComponent( mw.config.get( 'wgPageName' ) ), "stats", "ca-stats", "See article stats");

  // Button to check for external link status
mw.util.addPortletLink('p-cactions', 'http://toolserver.org/~dispenser/cgi-bin/webchecklinks.py?page='+ encodeURIComponent( mw.config.get( 'wgPageName' ) ), "links", "ca-chklinks", "Check external links");
}

  // Add extra edit button
//var addExtraButtons = function(){
//    mw.toolbar.addButton( {
//        imageFile: '//up.wiki.x.io/wikipedia/commons/5/5e/Button_template_join.png',
//        speedTip: 'Nowrap',
//        tagOpen: '{{nowrap|',
//        tagClose: '}}',
//        sampleText: '',
//        imageId: 'button-nowrap'
//    } );
//    mw.toolbar.addButton( {
//        imageFile: '//up.wiki.x.io/wikipedia/commons/9/94/Button_template_dev.png',
//        speedTip: 'Uncertainty',
//        tagOpen: '{{±|',
//        tagClose: '}}',
//        sampleText: '',
//        imageId: 'button-uncertainty'
//    } );
//    mw.toolbar.addButton( {
//        imageFile: '//up.wiki.x.io/wikipedia/commons/5/58/Button_small.png',
//        speedTip: 'Small',
//        tagOpen: '{{small|',
//        tagClose: '}}',
//        sampleText: '',
//        imageId: 'button-small'
//    } );
//};
//
//if( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
//    mw.loader.using( 'user.options', function () {
//        if ( ! mw.user.options.get( 'usebetatoolbar' ) ) {
//            mw.loader.using( 'mediawiki.action.edit', function(){
//                $( addExtraButtons );
//            } );
//        }
//    } );
//}
$.when( mw.loader.using( ['mediawiki.util'] ), $.ready ).done( setupPortletLinks );



var customizeToolbar = function () {
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
            buttonId: {
                label: 'Nowrap',
                type: 'button',
                icon: '//up.wiki.x.io/wikipedia/commons/5/5e/Button_template_join.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: '{{nowrap|',
                        peri: '',
                        post: '}}'
                    }
                }
            }
        }
    } );
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
            buttonId: {
                label: 'Uncertainty',
                type: 'button',
                icon: '//up.wiki.x.io/wikipedia/commons/9/94/Button_template_dev.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: '{{±|',
                        peri: '',
                        post: '}}'
                    }
                }
            }
        }
    } );
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
            buttonId: {
                label: 'Small',
                type: 'button',
                icon: '//up.wiki.x.io/wikipedia/commons/5/58/Button_small.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: '{{small|',
                        peri: '',
                        post: '}}'
                    }
                }
            }
        }
    } );
};

/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
	mw.loader.using( 'user.options' ).then( function () {
		// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
		if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
			$.when(
				mw.loader.using( 'ext.wikiEditor' ), $.ready
			).then( customizeToolbar );
		}
	} );
}