User:Mike Dillon/Scripts/tabs.js
< User:Mike Dillon | Scripts
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. |
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.
// Duplicate link tab from the top to the bottom of the content area
function morelinks() {
var tabs = document.getElementById('p-cactions').cloneNode(true);
tabs.id = 'mytabs';
var listitems = tabs.getElementsByTagName('LI');
for (i=0;i<listitems.length;i++) {
if(listitems[i].id) listitems[i].id = 'mytabs-' + listitems[i].id;
}
document.getElementById('column-content').appendChild(tabs);
}
runOnLoad(morelinks);
// Add a new list item to the page tabs
function addTab(url, name, id, title, key){
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlilink(tabs, url, name, id, title, key);
// Add tab to the bottom if the tabs have been cloned
var bottomTabsContainer = document.getElementById('mytabs');
if (bottomTabsContainer != null) {
var bottomTabs = bottomTabsContainer.getElementsByTagName('ul')[0];
addlilink(bottomTabs, url, name, 'mytabs-' + id, title, key);
}
}
// Add a 'purge' link to the tabs
function addPurge(){
ta['ca-purge'] = ['g', 'Purge the internal cache for this page'];
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(/=history/, "=purge"), 'purge', 'ca-purge');
akeytt();
}
runOnLoad(addPurge);
// Add a 'last' link to the tabs to show last diff
function doLastDiff() {
var nurl = "http://en.wikipedia.org/w/index.php?title=" + getPname() + "&diff=cur&oldid=prev";
document.location = nurl
}
function addLastDiff() {
var x = document.getElementById('ca-history');
if(!x) return;
ta['ca-last'] = ['', 'Show most recent diff'];
addTab('javascript:doLastDiff()', 'last', 'ca-last');
}
runOnLoad(addLastDiff);