User:Monchoman45/toolbar.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:Monchoman45/toolbar. |
/* toolbar.js, with lots of tools and stuff on it. */
/* originally designed for use on Wikia (wikifarm), hence the sysop and bureaucrat tools */
function ToolbarInit() {
CSS('#semanticToolbar {display:inline-block; float:right; line-height:15px; font-size:13px; margin-top:10px;} #semanticToolbar ul {list-style:none; display:inline;} #semanticToolbar ul li {display:inline;} .stb-button a {font-size:110%; padding:2px 6px 2px 6px; color:#fff; background-color:#2094dd; background-image:-moz-linear-gradient(top, #2094dd 35%, #006cb0 65%); background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(35%, #2094dd), color-stop(65%, #006cb0)); border:1px solid #006cb0; border-left:0;} .stb-button a:hover, .stb-button-selected a:hover {text-decoration:none; color:#000 !important; border:1px solid #cca81a !important; border-left:0 !important; background-color:#ffdb4d !important; background-image:-moz-linear-gradient(top, #ffdb4d 65%, #cca81a 35%) !important; background-image:-webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(35%, #ffdb4d), color-stop(65%, #cca81a)) !important; -moz-box-shadow:0 0 0.5em 0.1em #ffdb4d; -webkit-box-shadow:0 0 0.5em 0.1em #ffdb4d; box-shadow:0 0 0.5em 0.1em #ffdb4d; text-shadow:#999 1px 1px 1px;} .stb-button:first-child a {border-left:1px solid #006cb0; border-top-left-radius:1ex; border-bottom-left-radius:1ex; -moz-border-radius-bottomleft:1ex; -moz-border-radius-topleft:1ex;} .stb-button:first-child a:hover, .stb-button-selected:first-child a:hover {border-left:1px solid #cca81a !important;} .stb-button:last-child a, .stb-button-selected:last-child a, .stb-button-unusable:last-child span {border-top-right-radius:1ex; border-bottom-right-radius:1ex; -moz-border-radius-bottomright:1ex; -moz-border-radius-topright:1ex;} .stb-button-selected a { font-size:110%; text-decoration:none; color:#000 !important; padding:2px 6px 2px 6px; border:1px solid #cca81a; border-left:0; background-color:#ffdb4d; background-image:-moz-linear-gradient(top, #ffdb4d 65%, #cca81a 35%); background-image:-webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(35%, #ffdb4d), color-stop(65%, #cca81a)); -moz-box-shadow:0 0 0.5em 0.1em #ffdb4d; -webkit-box-shadow:0 0 0.5em 0.1em #ffdb4d; box-shadow:0 0 0.5em 0.1em #ffdb4d; text-shadow:#999 1px 1px 1px;} .stb-button-selected:first-child a {border-left:1px solid #cca81a; border-top-left-radius:1ex; border-bottom-left-radius:1ex; -moz-border-radius-bottomleft:1ex; -moz-border-radius-topleft:1ex;} .stb-button-unusable span {font-size:110%; cursor:default; color:#fff; padding:2px 6px 2px 6px; background-color:#eee; background-image:-moz-linear-gradient(top, #eee 35%, #ccc 65%); background-image:-webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(35%, #eee), color-stop(65%, #ccc)); border:1px solid #bbb; border-left:0;} .stb-button-unusable span:hover {text-decoration:none;} .stb-button-unusable:first-child span {border-left:1px solid #bbb; border-top-left-radius:1ex; border-bottom-left-radius:1ex; -moz-border-radius-bottomleft:1ex; -moz-border-radius-topleft:1ex;}');
switch(wgPageName) {
case 'Special:Contributions':
case 'Special:DeletedContributions':
window.wgSemanticPageName = 'User:' + $('input[name="target"]').attr('value');
window.wgSemanticNamespace = 'User';
window.wgSemanticTitle = $('input[name="target"]').attr('value');
window.wgSemanticUser = window.wgSemanticTitle;
break;
case 'Special:Editcount':
window.wgSemanticPageName = 'User:' + $('input[name="username"]').attr('value');
window.wgSemanticNamespace = 'User';
window.wgSemanticTitle = $('input[name="username"]').attr('value');
window.wgSemanticUser = window.wgSemanticTitle;
break;
case 'Special:Block':
window.wgSemanticPageName = 'User:' + $('input[name="wpBlockAddress"]').attr('value');
window.wgSemanticNamespace = 'User';
window.wgSemanticTitle = $('input[name="wpBlockAddress"]').attr('value');
window.wgSemanticUser = window.wgSemanticTitle;
break;
case 'Special:UserRights':
window.wgSemanticPageName = 'User:' + document.getElementById('username').value;
window.wgSemanticNamespace = 'User';
window.wgSemanticTitle = document.getElementById('username').value;
window.wgSemanticUser = window.wgSemanticTitle;
break;
case 'Special:MovePage':
window.wgSemanticPageName = document.getElementById('wpNewTitle').value;
if(wgCanonicalNamespace != '') {window.wgSemanticNamespace = window.wgSemanticPageName.split(':')[0]; window.wgSemanticTitle = window.wgSemanticPageName.split(':')[1];}
else {window.wgSemanticNamespace = ''; window.wgSemanticTitle = window.wgSemanticPageName;}
window.wgSemanticUser = window.wgTitle;
break;
case 'Special:Undelete':
window.wgSemanticPageName = $('.mw-undelete-pagetitle b a').html();
if(wgCanonicalNamespace != '') {window.wgSemanticNamespace = window.wgSemanticPageName.split(':')[0]; window.wgSemanticTitle = window.wgSemanticPageName.split(':')[1];}
else {window.wgSemanticNamespace = ''; window.wgSemanticTitle = window.wgSemanticPageName;}
window.wgSemanticUser = window.wgTitle;
break;
case 'Special:WhatLinksHere':
window.wgSemanticPageName = document.getElementById('mw-whatlinkshere-target').value;
if(wgCanonicalNamespace != '') {window.wgSemanticNamespace = window.wgSemanticPageName.split(':')[0]; window.wgSemanticTitle = window.wgSemanticPageName.split(':')[1];}
else {window.wgSemanticNamespace = ''; window.wgSemanticTitle = window.wgSemanticPageName;}
window.wgSemanticUser = window.wgTitle;
break;
case 'Special:PrefixIndex':
for(i in document.getElementById('namespace').getElementsByTagName('option')[i].selected == 'selected') {
window.wgSemanticNamespace = document.getElementById('namespace').getElementsByTagName('option')[i].innerHTML;
}
window.wgSemanticPageName = window.wgSemanticNamespace + ':' + document.getElementById('nsfrom').value;
window.wgSemanticTitle = document.getElementById('nsfrom').value;
window.wgSemanticUser = window.wgTitle;
break;
default:
window.wgSemanticUser = window.wgTitle;
if(wgCanonicalNamespace != '') {
window.wgSemanticPageName = wgFormattedNamespaces[wgNamespaceNumber] + ':' + wgTitle;
window.wgSemanticNamespace = wgFormattedNamespaces[wgNamespaceNumber];
window.wgSemanticTitle = wgTitle;
}
else {
window.wgSemanticPageName = wgTitle;
window.wgSemanticNamespace = '';
window.wgSemanticTitle = wgTitle;
}
break;
}
if(wgCanonicalNamespace == 'User' || wgCanonicalNamespace == 'User_talk') {wgSemanticUser = wgSemanticUser.split('/')[0];}
$('#bodyContent').prepend('<div id="semanticToolbar"><ul><li class="stb-button" id="wlhbutton"><a href="/wiki/Special:WhatLinksHere/' + wgSemanticPageName + '" title="Special:WhatLinksHere/' + wgSemanticPageName + '">WLH</a></li><li class="stb-button" id="prefixbutton"><a href="/wiki/Special:PrefixIndex/' + wgSemanticPageName + '" title="Special:PrefixIndex/' + wgSemanticPageName + '">Index</a></li></ul><ul><li class="stb-button" id="viewbutton"><a href="/w/index.php?title=' + wgSemanticPageName + '" title="' + wgSemanticPageName + '">View</a></li><li class="stb-button" id="editbutton"><a href="/w/index.php?title=' + wgSemanticPageName + '&action=edit" title="' + wgSemanticPageName + '&action=edit">Edit</a></li><li class="stb-button" id="histbutton"><a href="/w/index.php?title=' + wgSemanticPageName + '&action=history" title="' + wgSemanticPageName + '&action=history">History</a></li><li class="stb-button" id="movebutton" title="' + wgSemanticPageName + '&action=move"><a href="/wiki/Special:MovePage/' + wgSemanticPageName + '">Move</a></li><li class="stb-button" id="protbutton"><a href="/w/index.php?title=' + wgSemanticPageName + '&action=protect" title="' + wgSemanticPageName + '&action=protect">Protect</a></li><li class="stb-button" id="delbutton"><a href="/w/index.php?title=' + wgSemanticPageName + '&action=delete" title="' + wgSemanticPageName + '&action=delete">Delete</a></li></ul></div>');
if(wgPageName == 'Special:Contributions' || wgPageName == 'Special:Editcount' || wgPageName == 'Special:DeletedContributions' || wgPageName == 'Special:Block' || wgPageName == 'Special:UserRights' || wgPageName == 'Special:CreateBlogPage' || wgCanonicalNamespace == 'User' || wgCanonicalNamespace == 'User_talk') {
$('#semanticToolbar').prepend('<ul><li class="stb-button" id="contribsbutton"><a href="/wiki/Special:Contributions/' + wgSemanticUser + '" title="Special:Contributions/' + wgSemanticUser + '">Contribs</a></li><li class="stb-button" id="countbutton"><a href="/wiki/Special:Editcount/' + wgSemanticUser + '" title="Special:Editcount/' + wgSemanticUser + '">Edit Count</a></li><li class="stb-button" id="delcontribsbutton"><a href="/wiki/Special:DeletedContributions/' + wgSemanticUser + '" title="Special:DeletedContributions/' + wgSemanticUser + '">Del Contribs</a></li><li class="stb-button" id="blockbutton"><a href="/wiki/Special:Block/' + wgSemanticUser + '" title="Special:Block/' + wgSemanticUser + '">Block</a></li><li class="stb-button" id="rightsbutton"><a href="/wiki/Special:UserRights/' + wgSemanticUser + '" title="Special:UserRights/' + wgSemanticUser + '">Rights</a></li></ul>');
}
if(wgPageName == 'Special:Contributions' || wgPageName == 'Special:Editcount' || wgPageName == 'Special:DeletedContributions' || wgPageName == 'Special:Block' || wgPageName == 'Special:UserRights' || wgPageName == 'Special:CreateBlogPage') {
document.getElementById('contribsbutton').childNodes[0].href = '/wiki/Special:Contributions/' + wgSemanticUser;
document.getElementById('contribsbutton').childNodes[0].title = 'Special:Contributions/' + wgSemanticUser;
document.getElementById('countbutton').childNodes[0].href = '/wiki/Special:EditCount/' + wgSemanticUser;
document.getElementById('countbutton').childNodes[0].title = 'Special:EditCount/' + wgSemanticUser;
document.getElementById('blogbutton').childNodes[0].href = '/wiki/User_blog:' + wgSemanticUser;
document.getElementById('blogbutton').childNodes[0].title = 'User blog:' + wgSemanticUser;
document.getElementById('delcontribsbutton').childNodes[0].href = '/wiki/Special:DeletedContributions/' + wgSemanticUser;
document.getElementById('delcontribsbutton').childNodes[0].title = 'Special:DeletedContributions/' + wgSemanticUser;
document.getElementById('blockbutton').childNodes[0].href = '/wiki/Special:Block/' + wgSemanticUser;
document.getElementById('blockbutton').childNodes[0].title = 'Special:Block/' + wgSemanticUser;
document.getElementById('rightsbutton').childNodes[0].href = '/wiki/Special:UserRights/' + wgSemanticUser;
document.getElementById('rightsbutton').childNodes[0].title = 'Special:UserRights/' + wgSemanticUser;
}
//Mainspace page semantics
if(wgPageName == 'Special:MovePage' || wgPageName == 'Special:Undelete' || wgPageName == 'Special:WhatLinksHere' || wgPageName == 'Special:PrefixIndex') {
document.getElementById('viewbutton').childNodes[0].href = '/wiki/' + wgSemanticPageName;
document.getElementById('viewbutton').childNodes[0].title = 'View ' + wgSemanticPageName;
document.getElementById('editbutton').childNodes[0].href = '/w/index.php?title=' + wgSemanticPageName + '&action=edit';
document.getElementById('editbutton').childNodes[0].title = 'Edit ' + wgSemanticPageName;
document.getElementById('histbutton').childNodes[0].href = '/w/index.php?title=' + wgSemanticPageName + '&action=history';
document.getElementById('histbutton').childNodes[0].title = 'History of ' + wgSemanticPageName;
document.getElementById('movebutton').childNodes[0].href = '/wiki/Special:MovePage/' + wgSemanticPageName;
document.getElementById('movebutton').childNodes[0].title = 'Move ' + wgSemanticPageName;
document.getElementById('protbutton').childNodes[0].href = '/w/index.php?title=' + wgSemanticPageName + '&action=protect';
document.getElementById('protbutton').childNodes[0].title = 'Protect ' + wgSemanticPageName;
document.getElementById('delbutton').childNodes[0].href = '/w/index.php?title=' + wgSemanticPageName + '&action=delete';
document.getElementById('delbutton').childNodes[0].title = 'Delete ' + wgSemanticPageName;
document.getElementById('wlhbutton').childNodes[0].href = '/wiki/Special:WhatLinksHere/' + wgSemanticPageName;
document.getElementById('wlhbutton').childNodes[0].title = 'Special:WhatLinksHere/' + wgSemanticPageName;
document.getElementById('prefixbutton').childNodes[0].href = '/wiki/Special:PrefixIndex/' + wgSemanticPageName;
document.getElementById('prefixbutton').childNodes[0].title = 'Special:PrefixIndex/' + wgSemanticPageName;
}
//Stuff for wgPageName
switch(wgPageName) {
case 'Special:Contributions':
document.getElementById('contribsbutton').className = 'stb-button-selected';
break;
case 'Special:Editcount':
document.getElementById('countbutton').className = 'stb-button-selected';
break;
case 'Special:DeletedContributions':
document.getElementById('delcontribsbutton').className = 'stb-button-selected';
break;
case 'Special:Block':
document.getElementById('blockbutton').className = 'stb-button-selected';
break;
case 'Special:UserRights':
document.getElementById('rightsbutton').className = 'stb-button-selected';
break;
case 'Special:MovePage':
document.getElementById('movebutton').className = 'stb-button-selected';
document.getElementById('viewbutton').className = 'stb-button';
break;
case 'Special:Undelete':
document.getElementById('delbutton').className = 'stb-button-selected';
document.getElementById('viewbutton').className = 'stb-button';
break;
case 'Special:WhatLinksHere':
document.getElementById('wlhbutton').className = 'stb-button-selected';
break;
case 'Special:PrefixIndex':
document.getElementById('prefixbutton').className = 'stb-button-selected';
break;
}
//Stuff for wgAction
switch(wgAction) {
case 'view':
document.getElementById('viewbutton').className = 'stb-button-selected';
break;
case 'edit':
case 'submit': //They're pretty much the same thing
document.getElementById('editbutton').className = 'stb-button-selected';
break;
case 'history':
document.getElementById('histbutton').className = 'stb-button-selected';
break;
case 'protect':
document.getElementById('protbutton').className = 'stb-button-selected';
break;
case 'delete':
document.getElementById('delbutton').className = 'stb-button-selected';
break;
case 'purge':
document.getElementById('viewbutton').className = 'stb-button-selected'; //If you purged the page, you're viewing it
break;
}
//Turn off page actions on non-semantic special pages
if(wgCanonicalNamespace == 'Special' && wgPageName != 'Special:MovePage' && wgPageName != 'Special:WhatLinksHere' && wgPageName != 'Special:PrefixIndex' && wgPageName != 'Special:Undelete') {
document.getElementById('viewbutton').className = 'stb-button-selected';
document.getElementById('editbutton').className = 'stb-button-unusable';
document.getElementById('editbutton').innerHTML = '<span>Edit</span>';
document.getElementById('editbutton').childNodes[0].title = 'Special pages can\'t be edited';
document.getElementById('histbutton').className = 'stb-button-unusable';
document.getElementById('histbutton').innerHTML = '<span>History</span>';
document.getElementById('histbutton').childNodes[0].title = 'Special pages don\'t have history';
document.getElementById('movebutton').className = 'stb-button-unusable';
document.getElementById('movebutton').innerHTML = '<span>Move</span>';
document.getElementById('movebutton').childNodes[0].title = 'Special pages can\'t be moved';
document.getElementById('protbutton').className = 'stb-button-unusable';
document.getElementById('protbutton').innerHTML = '<span>Protect</span>';
document.getElementById('protbutton').childNodes[0].title = 'Special pages can\'t be protected';
document.getElementById('delbutton').className = 'stb-button-unusable';
document.getElementById('delbutton').innerHTML = '<span>Delete</span>';
document.getElementById('delbutton').childNodes[0].title = 'Special pages can\'t be deleted';
document.getElementById('wlhbutton').className = 'stb-button-unusable';
document.getElementById('wlhbutton').innerHTML = '<span>WLH</span>';
document.getElementById('wlhbutton').childNodes[0].title = 'Can\'t view what links to special pages';
document.getElementById('prefixbutton').className = 'stb-button-unusable';
document.getElementById('prefixbutton').innerHTML = '<span>Index</span>';
document.getElementById('prefixbutton').childNodes[0].title = 'Can\'t view index for special pages';
}
//Turn off protect for MediaWiki pages, and move for categories
if(wgCanonicalNamespace == 'MediaWiki' || wgSemanticNamespace == 'MediaWiki') {
document.getElementById('protbutton').className = 'stb-button-unusable';
document.getElementById('protbutton').innerHTML = '<span>Protect</span>';
document.getElementById('protbutton').childNodes[0].title = 'MediaWiki pages can\'t be protected';
}
if(wgCanonicalNamespace == 'Category' || wgSemanticNamespace == 'Category') {
document.getElementById('movebutton').className = 'stb-button-unusable';
document.getElementById('movebutton').innerHTML = '<span>Move</span>';
document.getElementById('movebutton').childNodes[0].title = 'Categories can\'t be moved';
}
//Remove functions that don't work on pages that don't exist
if($('.noarticletext').length != 0) {
document.getElementById('histbutton').className = 'stb-button-unusable';
document.getElementById('histbutton').innerHTML = '<span>History</span>';
document.getElementById('histbutton').childNodes[0].title = 'Non-existent pages have no history';
document.getElementById('movebutton').className = 'stb-button-unusable';
document.getElementById('movebutton').innerHTML = '<span>Move</span>';
document.getElementById('movebutton').childNodes[0].title = 'Non-existent pages can\'t be moved';
document.getElementById('delbutton').childNodes[0].innerHTML = 'Undelete';
document.getElementById('delbutton').childNodes[0].href = '/wiki/Special:Undelete/' + wgSemanticPageName;
document.getElementById('delbutton').childNodes[0].title = 'Special:Undelete/' + wgSemanticPageName;
document.getElementById('delbutton').id = 'undelbutton';
}
//Set the header to the semantic page
document.getElementById('Heading').innerHTML = wgSemanticPageName;
if(wgCanonicalNamespace == 'Special' && wgSemanticTitle != wgTitle) {document.getElementById('PageSubheader').innerHTML = wgPageName;}
//If you're on an oldid but not looking at a diff, set the header to show the oldid
if(urlQuery('oldid') != '' && urlQuery('diff') == '') {document.getElementById('PageSubheader').innerHTML = 'Viewing revision ' + urlQuery('oldid');}
//Get user rights
for(i in wgUserGroups) {
if(wgUserGroups[i] == 'autoconfirmed') {
autoconfirmed = true;
}
if(wgUserGroups[i] == 'sysop') {
admin = true;
}
if(wgUserGroups[i] == 'bureaucrat') {
bureaucrat = true;
}
if(wgUserGroups[i] == 'staff') {
staff = true;
}
if(wgUserGroups[i] == 'helper') {
helper = true;
}
if(wgUserGroups[i] == 'vstf') {
vstf = true;
}
}
//Turn off edit and move on semiprotected pages for non-autoconfirmed users
if(autoconfirmed == false) {
if(wgRestrictionEdit[0] == 'autoconfirmed') {
document.getElementById('editbutton').childNodes[0].innerHTML = 'Source';
document.getElementById('editbutton').childNodes[0].title = 'Page is edit protected (autoconfirmed)';
}
if(wgRestrictionMove[0] == 'autoconfirmed') {
document.getElementById('movebutton').className = 'stb-button-unusable';
document.getElementById('movebutton').innerHTML = '<span>Move</span>';
document.getElementById('movebutton').childNodes[0].title = 'Page is move protected (autoconfirmed)';
}
}
//Turn off sysop tools and edit on sysop protected pages for users with no admin privilages
if(admin == false && bureaucrat == false && staff == false && helper == false && vstf == false) {
document.getElementById('protbutton').className = 'stb-button-unusable';
document.getElementById('protbutton').innerHTML = '<span>Protect</span>';
document.getElementById('protbutton').childNodes[0].title = 'Need admin rights to protect pages';
document.getElementById('delbutton').className = 'stb-button-unusable';
document.getElementById('delbutton').innerHTML = '<span>Delete</span>';
document.getElementById('delbutton').childNodes[0].title = 'Need admin rights to delete pages';
document.getElementById('blockbutton').className = 'stb-button-unusable';
document.getElementById('blockbutton').innerHTML = '<span>Block</span>';
document.getElementById('blockbutton').childNodes[0].title = 'Need admin rights to block users';
document.getElementById('delcontribsbutton').className = 'stb-button-unusable';
document.getElementById('delcontribsbutton').innerHTML = '<span>Del Contribs</span>';
document.getElementById('delcontribsbutton').childNodes[0].title = 'Need admin rights to view deleted contributions';
if(wgRestrictionEdit[0] == 'sysop' || wgCanonicalNamespace == 'MediaWiki' || wgSemanticNamespace == 'MediaWiki') {
document.getElementById('editbutton').childNodes[0].innerHTML = 'Source';
document.getElementById('editbutton').childNodes[0].title = 'Page is edit protected (sysop)';
}
if(wgRestrictionMove[0] == 'sysop' || wgCanonicalNamespace == 'MediaWiki' || wgSemanticNamespace == 'MediaWiki') {
document.getElementById('movebutton').className = 'stb-button-unusable';
document.getElementById('movebutton').innerHTML = '<span>Move</span>';
document.getElementById('movebutton').childNodes[0].title = 'Page is move protected (sysop)';
}
}
if(bureaucrat == false && staff == false && helper == false && vstf == false) {
document.getElementById('rightsbutton').className = 'stb-button-unusable';
document.getElementById('rightsbutton').innerHTML = '<span>Rights</span>';
document.getElementById('rightsbutton').childNodes[0].title = 'Need bureaucrat rights to change user rights';
}
}
addOnloadHook(ToolbarInit);