User:WhitePhosphorus/common.js

维基百科,自由的百科全书

注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。

/**
 * To GIE/界面管理员/whoever script maintainer:
 * Some scripts from others are imported with `&oldid=` specified,
 * for security reasons. (Some are not as they require too many user scripts)
 * Please do not remove these `&oldid=`, thank you.
 * If something is deprecated and needs update, feel free to change the oldid.
 * 出于安全目的,如果不是调用了太多用户脚本,我都会使用 `&oldid=`
 * 来指定要加载的用户脚本版本,我自己的脚本除外。
 * 请不要删掉 `&oldid=`,谢谢您。如果有需要更新的东西,请更改对应的 oldid。
 */

importScript('User:WhitePhosphorus/js/log.js');
importScript('User:WhitePhosphorus/js/rrd.js');
importScript('User:WhitePhosphorus/js/PagePatroller.js');
//importScript('User:WhitePhosphorus/js/CommentsinLocalTime.js');
importScript('User:WhitePhosphorus/js/link-ts.js');
importScript('User:WhitePhosphorus/js/DetectDeleteReasons.js');
importScript('User:WhitePhosphorus/js/MonitorContrib.js');
importScript('User:WhitePhosphorus/js/macro.js');
importScript('User:WhitePhosphorus/js/macro-define.js');
importScript('User:WhitePhosphorus/js/AFLog-hideBots.js');
importScript('User:WhitePhosphorus/js/cutMyHand.js');
importScript('User:WhitePhosphorus/js/MagicRedirect.js');
importScript('User:WhitePhosphorus/js/CatUpdates.js');
importScript('User:WhitePhosphorus/js/all-in-one.js');
importScript('User:WhitePhosphorus/js/highlight.js');

// 旧版unblock-zh小工具,帮助用户重设密码用
mw.loader.load( '/w/index.php?title=User:Xiplus/js/unblock-zh-helper/load.js&oldid=73307130&action=raw&ctype=text/javascript' );

mw.loader.load( '/w/index.php?title=User:Alexander_Misel/Gadget-pageview.js&oldid=67358982&action=raw&ctype=text/javascript' );
mw.loader.load( '/w/index.php?title=User:Bluedeck/serve/ar-admin.js&oldid=58747940&action=raw&ctype=text/javascript' );

mw.loader.load( '/w/index.php?title=User:Xiplus/js/mass-revision-delete.js&oldid=58335166&action=raw&ctype=text/javascript' );
mw.loader.load( '/w/index.php?title=User:Xiplus/js/TranslateVariants.js&oldid=58810826&action=raw&ctype=text/javascript' );
mw.loader.load( '/w/index.php?title=User:Xiplus/js/close-affp.js&oldid=58610788&action=raw&ctype=text/javascript' );
mw.loader.load( '/w/index.php?title=User:Xiplus/js/apply-edit-from-abuselog.js&oldid=56834693&action=raw&ctype=text/javascript' );

(function($, mw) {
'use strict';

/* 到子页面的链接 */
var atoms = new Array([]);
var todo = $('<a></a>', {
	'href': '/wiki/User:WhitePhosphorus/磷原子1号/todo',
	'title': 'todo',
	'text': '填坑'
});
for (var i = 1; i < 5; i++) {
	atoms[i-1] = $('<a></a>', {
		'href': '/wiki/User:WhitePhosphorus/磷原子' + i + '号',
		'title': '/磷原子' + i + '号', 
		'text': (i == 1 ? '磷原子' : '') + i + '号'
	});
}
$("#pt-userpage").after($('<li></li>', {
	'id': 'pt-Atoms'
}).append(atoms[0]).append('(').append(todo).append(')-').append(atoms[1]).append('-').append(atoms[2]).append('-').append(atoms[3]));

/* 在左方链接栏的“互助客栈”链接下方添加其子页面 */
var vipSubps = new Array('消息', '方针', '技术', '求助', '条目探讨', '其他');
for (i = 0; i < vipSubps.length; i++) {
	var tmp = (i ? '#n-vipSubpage' + (i-1) : '#n-villagepump');
	$(tmp).after($('<li></li>', {
		'id': 'n-vipSubpage' + i
	}).append(' ').append($('<a></a>', {
		'href': '/wiki/Wikipedia:互助客栈/' + vipSubps[i],
		'title': '互助客栈/' + vipSubps[i],
		'text': vipSubps[i]
	})));
}

mw.loader.using(['mediawiki.util'], function() {
	/* 在条目的左方工具栏下添加“清理消歧义内链” */
	mw.util.addPortletLink(
  		"p-tb",
  		"http://c-69-142-160-183.hsd1.nj.comcast.net/~dispenser/cgi-bin/dab_solver.py?page=zh:" + mw.config.get('wgPageName'),
  		"清理消歧义内链"
	);
	
	$(mw.util.addPortletLink(
		"p-tb",
		"#",
		'强制显示摘要栏'
	)).click(function(e) {
		e.preventDefault();
		$('.mw-summary').attr('style', 'display: inline !important');
	});
});

/* 点击右上角的退出之前确认,再也不怕手滑啦 */
$.when($.ready).then(function() {
$('#pt-logout a').off('click').on('click', function(e) {
	if (!confirm('您点击了退出登录链接。确定要退出吗?')) {
		e.preventDefault();
	}
});
});

// [[:pt:MediaWiki:Gadget-FeedbackHighlight.js]] (ptwiki又是从fawiki抄的)
if ($('#ca-addsection').length || $('.standard-talk').length) {
	$(document.body).removeClass('ns-subject').addClass('ns-talk');
}

// Flow 点感谢居然没有确认,还不能 preventDefault,隐藏掉算了
$('.mw-thanks-flow-thank-link').hide();


mw.hook( 've.activationComplete' ).add( function () {
	// 可视化编辑器已加载完成
	var surface = ve.init.target.getSurface();
	console.log(surface.getMode());
	if ( surface.getMode() === 'visual' ) {
		console.log('v');
        // 可视化模式
        $('.source-show').hide();
        $('.visual-show').show();
    } else if ( surface.getMode() === 'source' ) {
    	console.log('s');
        // 可视化编辑器的源代码模式
        $('.source-show').show();
        $('.visual-show').hide();
    }
});
mw.hook( 've.deactivationComplete' ).add( function () {
	console.log('d');
	// 可视化编辑器切换到源代码编辑
    $('.source-show').show();
    $('.visual-show').hide();
});

})(jQuery, mw);

// wikEd settings
var wikEdConfig = {};
wikEdConfig.doCloneWarnings = false;  // 到底为什么要复制一遍editnotice。。。

// WikiEditor hack
mw.loader.using(['ext.wikiEditor'], function() {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'section': 'main',
	'group': 'insert',
	'tools': {
		'smile': {
			label: 'Smile!', // or use labelMsg for a localized label, see above
			type: 'button',
			icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: ":)" // text to be inserted
				}
			}
		}
	}
} );
});