User:Extremecircuitz/toolbarTweaks.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:Extremecircuitz/toolbarTweaks. |
// function to get toolbar by id for variables
function toolbar(toolbarId, isSearchbox) {
if (isSearchBox == 'true') {
document.getElementById(toolbarId);
} else {
document.getElementById(toolbarId).getElementsByTagName('ul')[0];
}
}
// Toolbar variables
userLinks = toolbar('p-personal', 'false'); // The links at the top right side of the page
userLinks.userpage = userLinks.getElementById('pt-userpage');
userLinks.talk = userLinks.getElementById('pt-mytalk');
userLinks.prefs = userLinks.getElementById('pt-preferences');
userLinks.watch = userLinks.getElementById('pt-watchlist');
userLinks.contribs = userLinks.getElementById('pt-mycontris');
userLinks.logout = userLinks.getElementById('pt-logout');
nav = toolbar('p-navigation', 'false'); // The navigation box
nav.randLink = nav.getElementById('n-randompage');
int = toolbar('p-interaction', 'false'); // The interaction box
int.recent = int.getElementById('n-recentchanges');
int.help = int.getElementById('n-help');
int.donate = int.getElementById('n-support');
search = toolbar('p-search', 'true'); // Search box
toolbox = toolbar('p-tb', 'false'); // toolbox
sidebar = nav + int + search + toolbox; // the entire sidebar minus the language box
tabs = toolbar('p-cactions', 'false'); // the tabs
// The page tab's id depends on the page's namespace, so it will not be added here until later
tabs.talk = tabs.getElementById('ca-talk');
tabs.edit = tabs.getElementById('ca-edit');
tabs.hist = tabs.getElementById('ca-history');
tabs.move = tabs.getElementById('ca-move');
tabs.watch = tabs.getElementById('ca-watch');
// Functions to add tabs to top and add links
function addTab(name, title, url, accessKey, id) {
var tabLink = document.createNode('a');
tabLink.setAttribute('href', url);
tabLink.setAttribute('title', title);
if (accessKey != null) tabLink.setAttribute('accesskey', accessKey);
tabName = document.createTextNode(name);
tabLink.childNode(tabName);
var newTab = document.createNode('li');
if (id != null) newTab.setAttribute('id', id);
newTab.childNode(tabLink);
tabs.appendChild(newTab);
}
function addNavLink(name, url, accessKey, id) {
var navLink = document.createNode('a');
navLink.setAttribute('href', url);
if (accessKey != null) navLink.setAttribute('accesskey', accessKey);
var navLinkText = document.createTextNode(name);
navLink.childNode(navLinkText);
var n = document.createNode('li');
if (id != null) n.setAttribute('id', id);
n.childNode(navLink);
nav.appendChild(n);
}
function addIntLink(name, url, accessKey, id) {
var intLink = document.createNode('a');
intLink.setAttribute('href', url);
if (accessKey != null) intLink.setAttribute('accesskey', accessKey);
var intLinkText = document.createTextNode(name);
intLink.childNode(intLinkText);
var i = document.createNode('li');
if (id != null) i.setAttribute('id', id);
i.childNode(intLink);
int.appendChild(i);
}
function addUserLink(name, url, accessKey, id, isUBXLink) {
var userLink = document.createNode('a');
userLink.setAttribute('href', url);
if (accessKey != null) userLink.setAttribute('accesskey', accessKey);
var userLinkText = document.createTextNode(name);
userLink.childNode(userLinkText);
var u = document.createNode('li');
if (id != null) u.setAttribute('id', id);
u.childNode(userLink);
if (isUBXLink == 'true') {
userLinks.talk.appendNode(n);
} else {
userLinks.appendChild(n);
}
}
// Some rearrangment to a couple of the links in sidebar, as well as some added links
nav.randLink.appendNode(int.recent).appendNode(int.help);
addIntLink('Department of Fun', '/wiki/WP:FUN');
addIntLink('The MS-DOS Game', '/wiki/WP:MSDOS');
addIntLink('Wikiholic Test', '/wiki/WP:HOLIC');
addUserLink('My Userboxes', '/wiki/User:Extremecircuitz/more_userboxes',,,'true');