[go: up one dir, main page]

Jump to content

User:Nardog/RefRenamer.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
mw.config.get('wgNamespaceNumber') % 2 === 0 &&
mw.config.get('wgArticleId') &&
mw.config.get('wgPageContentModel') === 'wikitext' &&
$.when($.ready, mw.loader.using('mediawiki.util')).then(function refRenamer() {
	if (!document.getElementById('p-tb')) return;
	let messages = Object.assign({
		portlet: 'RefRenamer',
		loading: 'Loading RefRenamer...'
	}, window.refrenamerMessages);
	let clicked;
	mw.util.addPortletLink('p-tb', '#', messages.portlet, 't-refrenamer').firstElementChild.addEventListener('click', e => {
		e.preventDefault();
		if (clicked) {
			if (window.refRenamer) window.refRenamer();
			return;
		}
		clicked = true;
		mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Nardog/RefRenamer-core.js&action=raw&ctype=text/javascript');
		mw.notify(messages.loading, {
			autoHideSeconds: 'long',
			tag: 'refrenamer'
		});
	});
});