본문으로 이동

사용자:피그사무라이/common.js

위키백과, 우리 모두의 백과사전.

참고: 설정을 저장한 후에 바뀐 점을 확인하기 위해서는 브라우저의 캐시를 새로 고쳐야 합니다. 구글 크롬, 파이어폭스, 마이크로소프트 엣지, 사파리: ⇧ Shift 키를 누른 채 "새로 고침" 버튼을 클릭하십시오. 더 자세한 정보를 보려면 위키백과:캐시 무시하기 항목을 참고하십시오.

// cat-a-lot
// window.catALotPrefs = {editpages: true};
// mw.loader.load('jquery.ui');
// mw.loader.load('//ko.wikipedia.org/w/index.php?title=User:Wikiwater2020/cat-a-lot.js&action=raw&ctype=text/javascript');
// mw.loader.load('//commons.wikimedia.org/w/index.php?action=raw&ctype=text/css&title=MediaWiki:Gadget-Cat-a-lot.css', 'text/css');

// Show reversion ID
mw.loader.load('//ko.wikipedia.org/w/index.php?title=사용자:Wikiwater2020/ShowReversionId.js&action=raw&ctype=text/javascript'); // [[User:Wikiwater2020/ShowReversionID.js]]

// mobileUndo 한글 버전. 기능이 제대로 동작하지 않을 수 있습니다.
mw.loader.load('//ko.wikipedia.org/w/index.php?title=User:Wikiwater2020/Undo.js&action=raw&ctype=text/javascript'); // [[User:Wikiwater2020/Undo.js]]

// test script
mw.loader.load('//ko.wikipedia.org/w/index.php?title=User:Wikiwater2020/rollback.js&action=raw&ctype=text/javascript'); // [[User:Wikiwater2020/rollback.js]]

// AjaxRollback from enwiki
// mw.loader.load('//en.wikipedia.org/w/index.php?title=User:DannyS712/AjaxRollback.js&action=raw&ctype=text/javascript'); // // [[User:DannyS712/AjaxRollback.js]]

// CatMan
mw.loader.load('//ko.wikipedia.org/w/index.php?title=User:Wikiwater2020/CatMan.js&action=raw&ctype=text/javascript'); //Linkback: [[User:Awesome Aasim/CatMan.js]]

// 완료/미완료된 요청 표시
mw.loader.load('//ko.wikipedia.org/w/index.php?title=User:Wikiwater2020/Req.js&action=raw&ctype=text/javascript');

// editing page with VSC
mw.loader.load("https://github.com/Frederisk/Wikitext-Extension-Gadget/releases/latest/download/index-vscode.js");

// MoreMenu
mw.loader.load('//ko.wikipedia.org/w/index.php?title=User:MemphisA5/MoreMenu.js&action=raw&ctype=text/javascript');

mw.loader.using( ['mediawiki.util', 'mediawiki.api'] ).then( function () {

function padWithZeroes( num ) {
	// Pad a number with zeroes. The number must be an integer where
	// 0 <= num < 100.
	return num < 10 ? '0' + num.toString() : num.toString(); 
}

function showTime( $target ) {
	var now = new Date();
	
	var timezone = window.LiveClockTimeZone || 'UTC';

	// Set the time.
	var hh, mm, ss;
	if ( timezone === "UTC" ) {
		hh = now.getUTCHours();
		mm = now.getUTCMinutes();
		ss = now.getUTCSeconds();
	} else if ( timezone === "local" ) {
		hh = now.getHours();
		mm = now.getMinutes();
		ss = now.getSeconds();
	} else {
		var newNow;
		try {
			newNow = new Date(
				now.toLocaleString(
					"en-US",
					{ timeZone: timezone }
				)
			);
			hh = newNow.getHours();
			mm = newNow.getMinutes();
			ss = newNow.getSeconds();
		} catch ( err ) {
			console.log( "LiveClock - error creating Date object with timezone '" + timezone + "': " + err.name);
			timezone = "UTC";
			newNow = now;
			hh = now.getUTCHours();
			mm = now.getUTCMinutes();
			ss = now.getUTCSeconds();
		}
	}
	var time = padWithZeroes( hh ) + ':' + padWithZeroes( mm ) + ':' + padWithZeroes( ss );
	$target.text( time );

	// Schedule the next time change.
	// 
	// We schedule the change for 100 ms _after_ the next clock tick. The delay
	// from setTimeout is not precise, and if we aim exactly for the tick, there
	// is a chance that the function will run slightly before it. If this
	// happens, we will display the same time for two seconds in a row - not
	// good. By scheduling 100 ms after the tick, we will always be about 100 ms
	// late, but we are also very likely to display a new time every second.
	var ms = now.getUTCMilliseconds();
	setTimeout( function () {
		showTime( $target );
	}, 1100 - ms );
}

function liveClock() {
	// Set CSS styles. We do this here instead of on the CSS page because some
	// wikis load this page directly, without loading the accompanying CSS.
	mw.util.addCSS( '#utcdate a { font-weight:bolder; font-size:120%; }' );

	// Reset whitespace that was set in the peer CSS gadget; this prevents the
	// effect of the p-personal menu jumping to the left when the JavaScript
	// loads.
	$( '.client-js > body.skin-vector #p-personal ul' ).css( 'margin-right', 'initial' );
	$( '.client-js > body.skin-monobook #p-personal ul' ).css( 'margin-right', 'initial' );

	// Add the portlet link.
	var dbName = mw.config.get( 'wgDBname' );
	var node = mw.util.addPortletLink(
		// We are experimenting with different locations for this in Vector 2022 based on feedback
		// so currently this is limited to MediaWiki.org
		document.getElementById( 'p-personal-more' ) && dbName === 'mediawikiwiki' ?
			'p-personal-more' : 'p-personal',
		mw.util.getUrl( null, { action: 'purge' } ),
		'',
		'utcdate'
	);
	if ( !node ) {
		return;
	}

	// Purge the page when the clock is clicked. We have to do this through the
	// API, as purge URLs now make people click through a confirmation screen.
	$( node ).on( 'click', function ( e ) {
		new mw.Api().post( { action: 'purge', titles: mw.config.get( 'wgPageName' ) } ).then( function () {
			location.reload();
		}, function () {
			mw.notify( 'Purge failed', { type: 'error' } );
		} );
		e.preventDefault();
	} );

	// Show the clock.
	showTime( $( node ).find( 'a:first' ) );
}

$( liveClock );
} );

var portletLink = mw.util.addPortletLink('p-personal', '#', "새 메뉴 항목", 'newMenuItem', "새 메뉴 항목을 가리킬 때 나타나는 문구", '', '');
$(portletLink).on('click', function(e) {
	e.preventDefault();
	alert("새 메뉴 항목을 눌렀어요!");
});

//ToDo list from enwiki
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:BrandonXLF/TodoList.js&action=raw&ctype=text/javascript');

// LintHint
mw.loader.load( "https://en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/lintHint/r.js&action=raw&maxage=86400&ctype=text/javascript" );

// prevent misclicking rollback link on mobile(test)
mw.loader.load( "https://ko.wikipedia.org/w/index.php?title=User:Wikiwater2020/sandbox.js&action=raw&ctype=text/javascript" );

// defaultsummaries
mw.loader.load('//ko.wikipedia.org/w/index.php?title=User:Bluehill/defaultsummaries.js&action=raw&ctype=text/javascript');