User:Mike Dillon/Scripts/tabs.js
< User:Mike Dillon | Scripts
Note – after saving, you may have to bypass your browser’s cache to see the changes.
- Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
- Konqueror and Chrome: click Reload or press F5;
- Opera: clear the cache in Tools → Preferences;
- Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.
- This script lacks a documentation subpage. Please create it.
- Useful links: root page • root page’s subpages • links • redirects • your own
// Requires: [[User:Mike Dillon/Scripts/i18n.js]]
/* 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
$(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"));
});