User:HiddenKnowledge/monobook.js

From IRC Wiki
< User:HiddenKnowledge
Revision as of 22:57, 5 May 2012 by HiddenKnowledge (talk | contribs) (Testing out some Javascript. (Again))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Note: After saving, 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.
jQuery( document ).ready( function() {
	var ns = mw.config.get( 'wgNamespaceNumber' );
	if ( ns !== 2 && ns !== 3 ) {
		return;  // restrict to User and User talk
	}

	var localtitles = {
			en: 'Block',
			pl: 'Zablokuj'
	};

	if( localtitles[wgUserLanguage] ) {
		TabTitle = localtitles[wgUserLanguage];
	} else {
		TabTitle = localtitles['en'];
	}

	var title = mw.config.get( 'wgTitle' );

	if ( title.indexOf( '/' ) != -1) { // If / occurs in the title
		title = title.substring( 0, title.indexOf( '/' ) ); // Strip it and anything after it from the title. This is to fix links from subpages.
	}

	// @todo: Use mw.msg when Gadgets 2.0 is out and messages can be loaded
	mw.util.addPortletLink(
		'p-cactions',
		mw.util.wikiGetlink( 'Special:Block/' + title ),
		TabTitle, 't-blockip', TabTitle + ' "' + title + '"'
	);
 
});