미디어위키:Gadget-PurgeTab.js

위키문헌 ― 우리 모두의 도서관.

참고: 설정을 저장한 후에 바뀐 점을 확인하기 위해서는 브라우저의 캐시를 새로 고쳐야 합니다.

  • 파이어폭스 / 사파리: Shift 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5 또는 Ctrl-R을 입력 (Mac에서는 ⌘-R)
  • 구글 크롬: Ctrl-Shift-R키를 입력 (Mac에서는 ⌘-Shift-R)
  • 인터넷 익스플로러 / 엣지: Ctrl 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5를 입력.
  • 오페라: Ctrl-F5를 입력.
jQuery(document).ready(function () {

	if (!mw.config.get('wgArticleId'))
		return;
	var link;

	link = mw.util.addPortletLink(
		'p-cactions', mw.util.getUrl(mw.config.get('wgPageName'), { 'action': 'purge' }),
		(mw.user.options.get( 'skin' ) == 'vector' ) ? "새로고침" : "*",
		'ca-purge', "이 문서의 캐시를 비웁니다.", '*'
	);

	link = mw.util.addPortletLink(
	// not sure if raw link is valid for extra params  Using wikiScript instead of getUrl
		'p-cactions', mw.util.wikiScript('api') + '?action=purge&titles=' + mw.config.get('wgPageName') + '&forcerecursivelinkupdate=1&redirects=1',
		(mw.user.options.get( 'skin' ) == 'vector' ) ? "강제 새로고침" : "**",
		'ca-purge-forcerecursivelinkupdate', "Purge with forced recursive-link table update", ','
	);

	link.addEventListener('click', function (ev) {
		mw.loader.using( 'mediawiki.api' ).done(function() {
			( new mw.Api() ).post({
				action: 'purge',
				pageids: mw.config.get('wgArticleId'),
				forcerecursivelinkupdate: 1,
				redirects: 1
			}).then(function () {
				location.reload();
			}, function (code, details) {
				var mesg;
				switch (code) {
				case 'http':
					mesg = 'HTTP error: ' + details.xhr.statusText;
					break;
				case 'ok-but-empty':
					mesg = 'Received empty response.';
					break;
				default:
					mesg = details.error.info;
				}
				mw.notify('<b>Hard purge failed</b>: ' + mesg);
				console.error(arguments);
			} );
		} );
		ev.preventDefault();
	}, false);

	link = mw.util.addPortletLink(
		'p-cactions', 'javascript:void window.warranty',
		(mw.user.options.get( 'skin' ) == 'vector' ) ? "빈 편집" : "***",
		'ca-nulledit', "빈 편집", '0'
	);

	link.addEventListener('click', function (ev) {
		mw.loader.using( 'mediawiki.api' ).done( function() {
			( new mw.Api() ).post({
				action: 'edit',
				pageid: mw.config.get('wgArticleId'),
				appendtext: '',
				watchlist: 'nochange',
				nocreate: '1',
				token: mw.user.tokens.get('csrfToken')
			}).then(function () {
				location.reload();
			}, function (code, details) {
				var mesg;
				switch (code) {
				case 'http':
					mesg = 'HTTP error: ' + details.xhr.statusText;
					break;
				case 'ok-but-empty':
					mesg = 'Received empty response.';
					break;
				default:
					mesg = details.error.info;
				}
				mw.notify('<b>Null edit failed</b>: ' + mesg);
				console.error(arguments);
			} );
		} );
		ev.preventDefault();
	}, false);

} );