User:Bob/monobook.js
Appearance
< User:Bob
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. |
![]() | The accompanying .css page for this skin is at User:Bob/monobook.css. |
/* <nowiki> */
function isYellowBox(el) {
if(el.className.search(/messagebox|standard-talk/i) != -1)
return true;
else
return false;
}
function wrapInMessageBox(el,wrapper) {
var newEl = el.cloneNode(true);
wrapper.appendChild(newEl);
el.parentNode.removeChild(el);
return newEl;
}
addOnloadHook(function(){
if(wgNamespaceNumber > 0 && wgNamespaceNumber % 2 != 0) { // if we're on a talk page
var autocollapse = true;
var pageEl = document.getElementById('contentSub').nextSibling;
while (pageEl.nodeType != 1) { // fix for Firefox
pageEl = pageEl.nextSibling;
}
if (isYellowBox(pageEl)) { // if there's a yellow box at the beginning
var tableIndex = 'YellowBoxes';
var collapseCaption = "hide";
var expandCaption = "show";
var table = document.createElement('table');
table.className = 'messagebox standard-talk collapsible collapsed';
table.style.background = '#FAF6ED';
table.setAttribute( "id", "collapsibleTable" + tableIndex );
var headtr = table.insertRow(0);
var header = document.createElement("th");
header.appendChild( document.createTextNode( "Talk page templates" ) );
header.style.textAlign = "center";
var bodytr = table.insertRow(1);
var td = bodytr.insertCell(0);
headtr.appendChild(header);
var Button = document.createElement( "span" );
var ButtonLink = document.createElement( "a" );
var ButtonText = document.createTextNode( collapseCaption );
Button.style.styleFloat = "right";
Button.style.cssFloat = "right";
Button.style.fontWeight = "normal";
Button.style.textAlign = "right";
Button.style.width = "6em";
ButtonLink.style.color = header.style.color;
ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
ButtonLink.setAttribute( "href", "javascript:collapseTable('" + tableIndex + "');" );
ButtonLink.appendChild( ButtonText );
Button.appendChild( document.createTextNode( "[" ) );
Button.appendChild( ButtonLink );
Button.appendChild( document.createTextNode( "]" ) );
header.insertBefore( Button, header.childNodes[0] );
document.getElementById('bodyContent').insertBefore(table,pageEl); // insert our table
var templates = new Array();
while(isYellowBox(pageEl)) { // keep moving through the page until we run out of yellow boxes
templates.push(pageEl);
pageEl = pageEl.nextSibling;
while (pageEl.nodeType != 1) { // fix for Firefox
pageEl = pageEl.nextSibling;
}
}
for (i = 0; i < templates.length; i++) {
templates[i] = wrapInMessageBox(templates[i],td); // put the templates in our new table
}
if(autocollapse)
collapseTable('YellowBoxes'); // collapse the table
}
}
});
importScript('User:Bob/script/addlimenu.js');
importScript('User:TheFearow/qstring.js');
importScript('MediaWiki:LinkFixr.js');
importScript('User:Ais523/stubtagtab.js');
importScript('User:Omegatron/monobook.js/autolinker.js');
importScript('User:Alex Smotrov/histcomb.js');
importScript('User:Alex Smotrov/qpreview.js');
importScript('User:Bob/script/easywelcome.js');
importScript('User:Bob/script/namespacesearch.js');
importScript('User:Bob/script/portlets.js');
importScript('User:Bob/script/clock.js');
importScript('User:Lupin/recent2.js');
importScript('User:Lupin/autoedit.js');
function getElementUrl(id) {
if (id) {
return id.firstChild.getAttribute('href', 2);
}
}
function getElementUrlText(id) {
if (id) {
return id.firstChild.innerHTML;
}
}
function getTheDate() {
var months = new Array("January", "February", "March",
"April", "May", "June", "July", "August", "September",
"October", "November", "December");
var d = new Date();
var curr_month = d.getMonth();
var curr_year = d.getFullYear();
return (months[curr_month] + curr_year);
}
if (wgNamespaceNumber >= 0)
addOnloadHook(function() {
var todaysDate = getTheDate();
var namespaces = new Array("", "Talk:", "User:", "User_talk:",
"Wikipedia:", "Wikipedia_talk:", "Image:", "Image_talk:",
"MediaWiki:", "MediaWiki_talk:", "Template:", "Template_talk:",
"Help:", "Help_talk:", "Category:", "Category_talk:",
"Portal:", "Portal_talk:");
/* set the page and talk page names for use throughout the page */
if(wgNamespaceNumber % 2 == 0) { // if it's not a talk page
var thisPage = namespaces[wgNamespaceNumber] + wgTitle;
var thisTalk = namespaces[wgNamespaceNumber + 1] + wgTitle;
thisPage = encodeURIComponent(thisPage);
thisTalk = encodeURIComponent(thisTalk);
var currentPage = thisPage;
} else {
var thisPage = namespaces[wgNamespaceNumber - 1] + wgTitle;
var thisTalk = namespaces[wgNamespaceNumber] + wgTitle;
thisPage = encodeURIComponent(thisPage);
thisTalk = encodeURIComponent(thisTalk);
var currentPage = thisTalk;
}
var pCactions = document.getElementById('p-cactions');
var tabs = pCactions.getElementsByTagName('ul')[0];
var caMain = pCactions.getElementsByTagName('li')[0];
var caTalk = pCactions.getElementsByTagName('li')[1];
var caEdit = document.getElementById('ca-edit');
var caView = document.getElementById('ca-viewsource');
var caHistory = document.getElementById('ca-history');
var caMove = document.getElementById('ca-move');
var caWatch = document.getElementById('ca-watch');
var caUnwatch = document.getElementById('ca-unwatch');
var caProtect = document.getElementById('ca-protect');
var caDelete = document.getElementById('ca-delete');
var caAdd = document.getElementById('ca-addsection');
var editText = (caView) ? 'view source' : 'edit';
// Hide tabs
if (caMain) caMain.style.display = 'none';
if (caEdit) caEdit.style.display = 'none';
if (caTalk) caTalk.style.display = 'none';
if (caView) caView.style.display = 'none';
if (caHistory) caHistory.style.display = 'none';
if (caMove) caMove.style.display = 'none';
if (caProtect) caProtect.style.display = 'none';
if (caDelete) caDelete.style.display = 'none';
if (caAdd) caAdd.style.display = 'none';
if (!caWatch) caWatch = caUnwatch;
var pageText = getElementUrlText(caMain);
var talkText = 'discussion'; // getElementUrlText(caTalk);
/* page menu */
var newPage = addLiMenu(tabs,pageText,caWatch);
if( caMain.className.search('new') == 0 ) {
addPortletLink(newPage.id,wgServer+wgScript+'?title='+thisPage+'&action=edit','create');
newPage.className += " red";
newPage.firstChild.nextSibling.className += " red";
} else {
addPortletLink(newPage.id,wgServer+wgScript+'?title='+thisPage,'view '+pageText);
addPortletLink(newPage.id,wgServer+wgScript+'?title='+thisPage+'&action=edit','edit');
addPortletLink(newPage.id,wgServer+wgScript+'?title='+thisPage+'&action=history','history');
addPortletLink(newPage.id,wgServer+wgScript+'?diff=cur&oldid=prev&title='+thisPage,'last');
if (caMove) addPortletLink(newPage.id,wgServer+'/wiki/Special:MovePage/'+ thisPage, 'move');
if (caProtect) addPortletLink(newPage.id,wgServer+wgScript+'?title='+thisPage+'&action=protect', 'protect');
if (caDelete) addPortletLink(newPage.id,wgServer+wgScript+'?title='+thisPage+'&action=delete', 'delete');
}
addPortletLink(newPage.id, wgServer + wgScript + '?title=Special:Log&page=' + thisPage, 'page log');
/* talk menu */
var newTalk = addLiMenu(tabs,talkText,caWatch);
if( caTalk.className.search('new') == 0 ) {
addPortletLink(newTalk.id,wgServer+wgScript+'?title='+thisTalk+'&action=edit','create');
newTalk.className += " red";
newTalk.firstChild.nextSibling.className += " red";
} else {
addPortletLink(newTalk.id,wgServer+wgScript+'?title='+thisTalk,'view '+talkText);
addPortletLink(newTalk.id,wgServer+wgScript+'?title='+thisTalk+'&action=edit','edit');
addPortletLink(newTalk.id,wgServer+wgScript+'?title='+thisTalk+'&action=edit§ion=new','add comment');
addPortletLink(newTalk.id,wgServer+wgScript+'?title='+thisTalk+'&action=history','history');
addPortletLink(newTalk.id,wgServer+wgScript+'?diff=cur&oldid=prev&title='+thisTalk,'last');
if (caMove) addPortletLink(newTalk.id,wgServer+'/wiki/Special:MovePage/'+ thisTalk, 'move');
if (caProtect) addPortletLink(newTalk.id,wgServer+wgScript+'?title='+thisTalk+'&action=protect', 'protect');
if (caDelete) addPortletLink(newTalk.id,wgServer+wgScript+'?title='+thisTalk+'&action=delete', 'delete');
}
addPortletLink(newTalk.id, wgServer + wgScript + '?title=Special:Log&page=' + thisTalk, 'page log');
/* if we're in the userspace, add more info */
if (wgNamespaceNumber == 2 || wgNamespaceNumber == 3) {
if ( wgTitle.indexOf("/") == -1 ) {
var uname = wgTitle;
} else {
var uname = wgTitle.substring(0, wgTitle.indexOf("/"));
}
var userMenu = addLiMenu(tabs,'user info');
addPortletLink(userMenu.id,wgServer+wgScript+'?title=Special:PrefixIndex&from='+uname+'/&namespace=2', 'userspace');
addPortletLink(userMenu.id, 'http://tools.wikimedia.de/~interiot/cgi-bin/Tool1/wannabe_kate?site=en.wikipedia.org&username='+uname, 'edit count');
addPortletLink(userMenu.id,wgServer+'/wiki/Special:Contributions/'+uname,'contribs');
addPortletLink(userMenu.id,wgServer+wgScript+'?title=Special:DeletedContributions&target='+uname,'deleted contribs');
addPortletLink(userMenu.id, wgServer+wgScript+'?title=Special:Log&user='+uname,'user log');
addPortletLink(userMenu.id, wgServer+wgScript+'?title=Special:Log&type=block&user='+uname,'block log');
if (caDelete) addPortletLink(userMenu.id,wgServer+"/wiki"+'/Special:Blockip/'+uname,'block');
}
var cleanupMenu = addLiMenu(tabs,'cleanup');
addPortletLink(cleanupMenu.id,'/w/index.php?title='+currentPage+'&action=edit&tag=cleanup','cleanup');
addPortletLink(cleanupMenu.id,'/w/index.php?title='+currentPage+'&action=edit&tag=wikify','wikify');
addPortletLink(cleanupMenu.id,'/w/index.php?title='+currentPage+'&action=edit&tag=notability','notability');
addPortletLink(cleanupMenu.id,'/w/index.php?title='+currentPage+'&action=edit&tag=pov','neutrality');
addPortletLink(cleanupMenu.id,'/w/index.php?title='+currentPage+'&action=edit&tag=crystal|date='+todaysDate, 'crystal ball');
addPortletLink(cleanupMenu.id,'/w/index.php?title='+currentPage+'&action=edit&tag=context','little context');
addPortletLink(cleanupMenu.id,'/w/index.php?title='+currentPage+'&action=edit&tag=uncategorized', 'uncategorized');
addPortletLink(cleanupMenu.id,'/w/index.php?title='+currentPage+'&action=edit&tag=unreferenced','unreferenced');
addPortletLink(cleanupMenu.id,'/w/index.php?title='+currentPage+'&action=edit&tag=onesource','one source');
addPortletLink(cleanupMenu.id,'/w/index.php?title='+currentPage+'&action=edit&tag=refimprove','more refs');
addPortletLink(cleanupMenu.id,'/w/index.php?title='+currentPage+'&action=edit&tag=copyedit','copyedit');
addPortletLink(cleanupMenu.id,'/w/index.php?title='+currentPage+'&action=edit&tag=rewrite','rewrite');
addPortletLink(cleanupMenu.id,'/w/index.php?title='+currentPage+'&action=edit&tag=notenglish','foreign lang');
addPortletLink(cleanupMenu.id,'/w/index.php?title='+currentPage+'&action=edit&tag=internallinks','no links');
addPortletLink(cleanupMenu.id,'/w/index.php?title='+currentPage+'&action=edit&tag=expand','expand');
addPortletLink(cleanupMenu.id,'/w/index.php?title='+currentPage+'&action=edit&tag=update','update');
addPortletLink(cleanupMenu.id,'/w/index.php?title='+currentPage+'&action=edit&tag=trivia','trivia');
addPortletLink(cleanupMenu.id,'/w/index.php?title='+currentPage+'&action=edit&tag=hoax','hoax');
if(QueryString.exists('tag')) {
if(document.getElementById('mw-recreate-deleted-warn') || document.getElementById('noarticletext')) {
alert('You are about to (re)create a page that does not exist; tagging has been aborted.');
return;
}
var tagText = QueryString.get('tag');
var f = document.editform, t = f.wpTextbox1;
t.value = "{" + "{" + tagText + "}}\n" + t.value;
f.wpSummary.value = "adding {{"+tagText+"}} tag";
f.wpSave.click();
return;
}
var csdMenu = addLiMenu(tabs,'csd');
addPortletLink(csdMenu.id,'/w/index.php?title='+currentPage+'&action=edit&csd=db-g1','nonsense');
addPortletLink(csdMenu.id,'/w/index.php?title='+currentPage+'&action=edit&csd=db-g2','test');
addPortletLink(csdMenu.id,'/w/index.php?title='+currentPage+'&action=edit&csd=db-g3','vandalism');
addPortletLink(csdMenu.id,'/w/index.php?title='+currentPage+'&action=edit&csd=db-g10','attack');
addPortletLink(csdMenu.id,'/w/index.php?title='+currentPage+'&action=edit&csd=db-g11','spam/ad');
addPortletLink(csdMenu.id,'/w/index.php?title='+currentPage+'&action=edit&csd=db-bio','bio');
addPortletLink(csdMenu.id,'/w/index.php?title='+currentPage+'&action=edit&csd=db-band','band');
addPortletLink(csdMenu.id,'/w/index.php?title='+currentPage+'&action=edit&csd=db-inc','corporation');
addPortletLink(csdMenu.id,'/w/index.php?title='+currentPage+'&action=edit&csd=db-group','organization');
addPortletLink(csdMenu.id,'/w/index.php?title='+currentPage+'&action=edit&csd=db-a2','foreign lang');
addPortletLink(csdMenu.id,'/w/index.php?title='+currentPage+'&action=edit&csd=db-a7','insignificant');
addPortletLink(csdMenu.id,'/w/index.php?title='+currentPage+'&action=edit&csd=db-a1','no context');
addPortletLink(csdMenu.id,'/w/index.php?title='+currentPage+'&action=edit&csd=db-a3','empty');
addPortletLink(csdMenu.id,'/w/index.php?title='+currentPage+'&action=edit&csd=other','other...');
if(QueryString.exists('csd')) {
if(QueryString.get('csd') == 'other') {
var csdText = prompt('Please type a reason for speedy deletion:');
csdText = 'db|'+csdText;
} else {
var csdText = QueryString.get('csd');
}
var f = document.editform, t = f.wpTextbox1;
if(t.value.substr(0,2) == "{"+"{") {
if(!confirm('There is another template on this page. Continue tagging?'))
return;
} else {
if(document.getElementById('mw-recreate-deleted-warn') || document.getElementById('noarticletext')) {
alert('You are about to (re)create a page that does not exist; tagging has been aborted.');
return;
}
}
t.value = "{" + "{" + csdText + "}}\n" + t.value;
f.wpSummary.value = "Requesting speedy deletion per [[WP:CSD]]";
f.wpSave.click();
return;
}
});
/* </nowiki> */