跳转到内容

User:Aizag/common.js

维基百科,自由的百科全书
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
/*** BEGIN WIKIBREAK ENFORCER ***/
/*** From [[:en:Wikipedia:WikiProject User scripts/Scripts/WikiBreak Enforcer/script]] ***/
$(function() {
	/*** 编辑此处 ***/
	// 你的假期何时结束?
	// 没有前导零,如 7 ~ 正确,但是 07 ~ 错误。
	var date = {year: 2025, month: 6, day: 1};
	var time = {hours: 0, minutes: 0, seconds: 0};

	/*** 不要编辑以下内容 ***/
	var currentDate = new Date();
	var enforcedBreakEnd = new Date(date.year, date.month - 1, date.day, time.hours, time.minutes, time.seconds);
	if (currentDate > enforcedBreakEnd) return;
	mw.loader.using(['ext.gadget.site-lib', 'mediawiki.api']).then(function() {
		window.alert(wgULS('您的维基假期将在', '您的維基假期將在') + enforcedBreakEnd.toLocaleString() + wgULS('结束\n', '結束\n') + wgULS('现在是:', '現在是:') + currentDate.toLocaleString() + '\n\n' + wgULS('再见!', '再見!'));
		new mw.Api().postWithEditToken({
			action: 'logout'
		}).done(function() {
			window.location = window.location.origin + '/w/index.php?title=Special:Userlogin&returnto=Wikipedia:首页';
		}).fail(function() {
			console.log('logout failed');
		});
	});
});
/*** END WIKIBREAK ENFORCER ***/
( function( $, mw, window ) {
mw.loader.using('ext.gadget.tipsyDeprecated').then( function() {

	mw.hook( 'wikipage.content' ).add( function( $content ) {
		$( '.ilh-all', $content ).not( '.ilh-blue' ).on( 'internalLinkHelper-close', function( event ) {
			var $this = $( this );
			if ( $this.data( 'internalLinkHelper-showing' ) ) {
				$( this ).removeClass( 'ilh-active' ).find( '.ilh-page a' ).tipsy( 'hide' ).end()
					.data( 'internalLinkHelper-showing', false );
			}
		} ).each( function() {
			var origTitle = $( this ).data( 'orig-title' ),
				$foreignSpan = $( '.ilh-link', this ),
				$linkAnchor = $( '.ilh-page a', this ),
				$langSpan = $( '.ilh-lang', this ),
				langName = $langSpan.text(),
				$that = $( this ).data( 'internalLinkHelper-showing', false );

			if ( !$linkAnchor || !$linkAnchor.length || !$linkAnchor.tipsy ) {
				return;
			}

			var timeout = null;
			
			var maybeClearTimeout = function() {
				if ( timeout !== null ) {
					clearTimeout( timeout );
				}
			}, autoSetTimeout = function() {
				maybeClearTimeout();
				timeout = setTimeout.apply( null, arguments );
			};
			
			var mouseleave = function() {
				autoSetTimeout( function() {
					$that.trigger( 'internalLinkHelper-close' );
				}, 500 );
			}, mouseenter = function() {
				if ( $that.data( 'internalLinkHelper-showing' ) ) {
					maybeClearTimeout();
				} else {
					$( '.ilh-all', $content ).not( $that ).trigger( 'internalLinkHelper-close' );
					$that.addClass( 'ilh-active' ).data( 'internalLinkHelper-showing', true );
					var tipsy = $linkAnchor.tipsy( 'show' );
					// please revise as necessary
					if(tipsy) {
						tipsy = tipsy.tipsy( true );
						if(tipsy && tipsy.tip) {
							tipsy.tip().mouseleave( mouseleave ).mouseenter( mouseenter );
						}
					}
				}
			};
			$linkAnchor.tipsy( {
				className: 'ilh-tipsy',
				gravity: 'nw',
				html: true,
				trigger: 'manual',
				title: function() {
					return '<div>'
						+ wgUVS( '条目“', '條目「' )
						+ $( '<span/>' ).text( origTitle ).html()
						+ wgUVS( '”尚未创建,可参考', '」尚未創建,可參考' )
						+ $( '<span/>' ).text( langName ).html()
						+ wgUVS( '维基百科的对应页面:', '維基百科的對應頁面:' )
						+ $foreignSpan.html()
						+ '。</div>';
				}
			} )
			.mouseleave( mouseleave ).mouseenter( mouseenter );
		} );
	} );
} ); } )( jQuery, mediaWiki, window );