User:Mike Dillon/Scripts/tabs.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:Mike Dillon/Scripts/tabs. |
// Requires: [[User:Mike Dillon/Scripts/i18n.js]]
/* <pre><nowiki> */
/* Messages */
wfAddMsg("en", "purgeTabLabel", "Purge");
wfAddMsg("es", "purgeTabLabel", "Purgar");
wfAddMsg("en", "purgeTabTitle", "Purge this page from the server cache");
wfAddMsg("es", "purgeTabTitle", "Purgar esta página del cache de servidor");
wfAddMsg("en", "lastDiffTabLabel", "Last");
wfAddMsg("es", "lastDiffTabLabel", "Previa");
wfAddMsg("en", "lastDiffTabTitle", "Show differences between this revision and the previous");
wfAddMsg("es", "lastDiffTabTitle", "Mostrar las diferencias entre esta revisión y la previa");
// Add a new list item to the page tabs
function addTab(url, name, id, title, key) {
// Add tab to the top tabs
mw.util.addPortletLink('p-cactions', url, name, id, title, key);
// Add tab to the bottom if the tabs have been cloned
mw.util.addPortletLink('mytabs', url, name, 'mytabs-' + id, title, key);
}
// Add a 'purge' and 'last' links to the tabs
addOnloadHook(function () {
var x = document.getElementById('ca-history');
if(!x) return;
if(x.children) x = x.children[0].href;
else x = x.childNodes[0].href;
addTab(x.replace(/action=history/, "action=purge"),
wfMsg("purgeTabLabel"), 'ca-purge', wfMsg("purgeTabTitle"));
addTab(x.replace(/action=history/, "diff=" + wgCurRevisionId + "&oldid=prev"),
wfMsg("lastDiffTabLabel"), 'ca-last', wfMsg("lastDiffTabTitle"));
});
/* </nowiki></pre> */