User:94rain/Gadget-MySandbox.js

注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:Ctrl-F5
/**
 * Add a "My sandbox" link to the personal portlet menu.
 *
 * Required modules: mediawiki.util, mediawiki.Title, mediawiki.Uri
 *
 * @source https://www.mediawiki.org/wiki/Snippets/MySandbox
 * @version 2014-07-16
 */
( function ( mw, $ ) {
	$( function () {
		var conf, title, url;

		// Customize/Translate this to your needs
		conf = {
			subpageName: '沙盒',
			portletLabel: '沙盒',
			portletTooltip: '前往沙盒',
			editintroPagename: 'Template:User_sandbox',
			preloadPagename: 'Template:User_sandbox/preload'
		};
		// Don't alter the code below

		// Use Special:MyPage (as opposed to mw.user.getName()) so that it
		// works for logged-out users as well.
		title = new mw.Title( 'Special:MyPage/' + conf.subpageName );

		url = new mw.Uri( title.getUrl() );

		mw.util.addPortletLink(
			'p-personal',
			url,
			conf.portletLabel,
			'pt-sandbox',
			conf.portletTooltip,
			null,
			'#pt-preferences'
		);
	} );
}( mediaWiki, jQuery ) );