User:Jeeputer/InternationalRefRenamer.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Jeeputer/InternationalRefRenamer. |
//This is a fork of [[User:Nardog/RefRenamer]] which suppose to support internationalization
//For more information see https://en.wikipedia.org/wiki/Special:Permalink/1140828312#i18n
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;
if (mw.config.get('wgUserName') !== 'Jeeputer') return; // Currently testing
let clicked;
let lang = mw.config.get('wgContentLanguage');
let i18n;
$.getJSON('/w/index.php', {
action: 'raw',
ctype: 'application/json',
title: 'User:Jeeputer/InternationalRefRenamer.js/i18n.json'
}).then(function(data) {
i18n = data[lang] || data['en']; // fall back to En if lang data missing
window.RefRenameri18n = i18n;
mw.util.addPortletLink('p-tb', '#', i18n['tool-name'], 't-refrenamer').firstElementChild.addEventListener('click', e => {
e.preventDefault();
if (clicked) {
if (window.refRenamer) window.refRenamer();
return;
}
clicked = true;
mw.notify(i18n['tool-loading'], {
autoHideSeconds: 'long',
tag: 'refrenamer'
});
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Jeeputer/InternationalRefRenamer-core.js&action=raw&ctype=text/javascript');
});
});
});