User:RoyBoy/monobook.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. |
![]() | The accompanying .css page for this skin is at User:RoyBoy/monobook.css. |
// Big thanks to User:JesseW for leading me to:
// [[Wikipedia:WikiProject_User_scripts/Techniques#Onload_Structure]]
// and to User:Sasquatch for the if(document.get ... code
// References:
// http://en.wikipedia.org/wiki/MediaWiki:Monobook.js
// User:JesseW/monobook.js --- User:Drini/monobook.js
//
// RoyBoy - Working version done: Nov 2 2005 @ 7:44 PM EST
// Shortens edit, protect, talk and delete tabs
//
// Nov 10 2005: Added contrib and block tab, with default other time
//
// Optimized for 800x600 res. used with CDVF, see at:
// http://www.flickr.com/photos/34345738@N00/62015752/
// <nowiki>
// cite toolbar script
importScript('User:Mr.Z-man/refToolbar 2.0.js');
//////////////////////////////////////////
// Tabs by Korath
// returns <li><a href="url">name</a></li>
/////////////////////////////////////////
function addlilink(url, name)
{
var na = document.createElement('a');
na.setAttribute('href', url);
var txt = document.createTextNode(name);
na.appendChild(txt);
var li = document.createElement('li');
li.appendChild(na);
return li;
}
// appends msg to the currently-editted page, sets the summary to summ,
// and marks or unmarks the Watch this page checkbox according to watch.
function edit_summary_watch(msg, summ, watch)
{
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += msg;
f.wpSummary.value = summ;
}
function test()
{
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += "{{subst:" + "test" + "}} -" + " " + "~" + "~" + "~" + "~";
f.wpSummary.value = "test warning";
}
function testn(number)
{
var page = prompt("Vandalism to which article?")
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += "{{subst:" + "test" + number + "-n|" + page + "}} -" + " " + "~" + "~" + "~" + "~";
if (t.value > 2)
f.wpSummary.value = "Vandalism to [[" + page + "]] - warning " + number;
else
f.wpSummary.value = "test [[" + page + "]]";
}
function test2(number)
{
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += "{{subst:" + "test" + number + "}} -" + " " + "~" + "~" + "~" + "~";
f.wpSummary.value = "test warning";
}
function blankwarn()
{
//var page = prompt("Vandalism to which article?")
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += "{{subst:" + "test2a" + "}} -" + " " + "~" + "~" + "~" + "~";
f.wpSummary.value = "t2a";
}
function bvn()
{
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += "{{subst:" + "Blatantvandal" + "}} -" + " " + "~" + "~" + "~" + "~";
f.wpSummary.value = "bv";
//var page = prompt("Vandalism to which article?")
//var f = document.editform, t = f.wpTextbox1;
//if (t.value.length > 0)
// t.value += '\n';
//t.value += "{{subst:" + "Blatantvandal" + "}} -" + " " + "~" + "~" + "~" + "~";
//f.wpSummary.value = "Blatant vandal";
//f.wpSummary.value = "bv [[" + page + "]]";
}
// adds various tabs to call the above
function add_tabs()
{
var c1 = document.getElementById('column-one');
var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
// Only add contribs tab for "User talk:" but not while Editing
if (document.title.indexOf("User") != -1 && document.title.indexOf("Editing User talk:"))
{
// use the "edit this page" tab to get already-tidied url
var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
// cut everything up to "title=" from the start and everything past "&action=edit" from the end
editlk = editlk.substring(editlk.indexOf('title=') + 6, editlk.lastIndexOf('&action=edit'));
editlk = editlk.substring(editlk.indexOf(':') + 1);
var slloc = editlk.indexOf('/');
if (slloc > 0)
editlk = editlk.substring(0, slloc);
tabs.appendChild(addlilink('/wiki/Special:Contributions/' + editlk, 'c'));
}
// Only add for pages with "Editing User talk:" somewhere in the title
if (document.title.indexOf("Editing User talk:") != -1)
{
//change move > m, hist > h, pro > p, del > d for more room
if(document.getElementById('ca-talk'))
document.getElementById('ca-talk').firstChild.innerHTML = 't';
if(document.getElementById('ca-edit'))
document.getElementById('ca-edit').firstChild.innerHTML = 'e';
if(document.getElementById('ca-move'))
document.getElementById('ca-move').firstChild.innerHTML = 'm';
if(document.getElementById('ca-history'))
document.getElementById('ca-history').firstChild.innerHTML = 'h';
if(document.getElementById('ca-protect'))
document.getElementById('ca-protect').firstChild.innerHTML = 'p';
if(document.getElementById('ca-delete'))
document.getElementById('ca-delete').firstChild.innerHTML = 'd';
//change "user page" tab to "anon" to put them in their place, HA!
if(document.getElementById('ca-nstab-user'))
document.getElementById('ca-nstab-user').firstChild.innerHTML = 'anon';
//tabs.appendChild(addlilink('javascript:edit_summary_watch("{{" + "subst:anon}} -" + " " + "~" + "~" + "~" + "~", "{{" + "anon}}", false, 0)',"Anon"));
//tabs.appendChild(addlilink('javascript:edit_summary_watch("{{" + "subst:welcome}} -" + " " + "~" + "~" + "~" + "~", "Welcome!", false, 0)',"Welcome!"));
tabs.appendChild(addlilink('javascript:test()',"1"));
//tabs.appendChild(addlilink('javascript:blankwarn(2)',"t2"));
tabs.appendChild(addlilink('javascript:blankwarn()',"2a"));
tabs.appendChild(addlilink('javascript:test2(3)',"t3"));
//tabs.appendChild(addlilink('javascript:testn(4)',"t4"));
tabs.appendChild(addlilink('javascript:bvn(1)',"bv"));
tabs.appendChild(addlilink('javascript:edit_summary_watch(":{{" + "subst:test5}} -" + " " + "~" + "~" + "~" + "~", "Blocked user!", true, 1)',"5"));
}
if (document.title.indexOf("Editing Wikipedia:Articles for deletion") != -1)
{
tabs.appendChild(addlilink('javascript:closeafd("keep", "")', 'Keep', ''));
tabs.appendChild(addlilink('javascript:closeafd("delete", "")', 'Delete', ''));
tabs.appendChild(addlilink('javascript:closeafd(prompt("Result?"), "")', 'Other', ''));
}
}
// Simplified edit section 0 ([[User:ais523/editsection0tab.js]])
// Loosely based on [[Wikipedia:WikiProject User scripts/Scripts/Add edit section 0]]
// <source lang="javascript">
$(function()
{
var x=document.getElementById('ca-history');
if(x!=null)
addPortletLink('p-cactions', mw.config.get('wgServer')+mw.config.get('wgScript')+"?title="+encodeURIComponent(mw.config.get('wgPageName'))+
"&action=edit§ion=0", '0', 'ca-edit-0',
'Edit the lead section of this page', '0', x);
});
function shortTabs() {
if(document.getElementById('ca-edit'))
document.getElementById('ca-edit').firstChild.innerHTML = 'edit';
if(document.getElementById('ca-history'))
document.getElementById('ca-history').firstChild.innerHTML = 'hist';
if(document.getElementById('ca-protect'))
document.getElementById('ca-protect').firstChild.innerHTML = 'pro';
if(document.getElementById('ca-unprotect'))
document.getElementById('ca-unprotect').firstChild.innerHTML = 'unp';
if(document.getElementById('ca-talk'))
document.getElementById('ca-talk').firstChild.innerHTML = 'talk';
if(document.getElementById('ca-delete'))
document.getElementById('ca-delete').firstChild.innerHTML = 'del';
if(document.getElementById('ca-unwatch'))
document.getElementById('ca-unwatch').firstChild.innerHTML = 'unw';
if(document.getElementById('ca-watch'))
document.getElementById('ca-watch').firstChild.innerHTML = 'w';
if(document.getElementById('ca-move'))
document.getElementById('ca-move').firstChild.innerHTML = 'm';
}
// Adds a "blocklog" tab and fills in the username field on Special:Blockip, if a "&faketarget=username" is present.
function do_blockip_stuff()
{
// focus on Reason field
document.getElementsByName('wpBlockReason')[0].focus();
// Look for a &faketarget= for the username/ip
var l = location.search.substring(1).split('&');
var target = '';
for (var i = 0; i < l.length; ++i)
{
var n = l[i].indexOf('=');
if (l[i].substring(0, n) == 'faketarget')
{
target = l[i].substring(n + 1);
break;
}
}
if (target == '')
return;
// put account name in "IP Address/username" field
var addr = document.getElementsByName('wpBlockAddress')[0];
addr.value = unescape(target);
// insert a default ban time
var defaultTime = document.getElementsByName('wpBlockOther')[0];
defaultTime.value = "33 hours";
// add "blocklog" tab
var c1 = document.getElementById('column-one');
var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
tabs.appendChild(addlilink('/w/index.php?title=Special%3ALog&type=block&user=&page=User%3A' + target, 'blocklog'));
}
// Adds "block" and "blocklog" tabs to User: and User talk: pages.
function add_block_tab()
{
var c1 = document.getElementById('column-one');
var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
// use the "edit this page" tab to get already-tidied url
var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
// cut everything up to "title=" from the start and everything past "&action=edit" from the end
editlk = editlk.substring(editlk.indexOf('title=') + 6, editlk.lastIndexOf('&action=edit'));
editlk = editlk.substring(editlk.indexOf(':') + 1);
var slloc = editlk.indexOf('/');
if (slloc > 0)
editlk = editlk.substring(0, slloc);
// add "block" tab
tabs.appendChild(addlilink('/w/index.php?title=Special%3ABlockip&faketarget=' + editlk, 'b'));
// add count tab
tabs.appendChild(addlilink('http://tools.wikimedia.de/~interiot/cgi-bin/Tool1/wannabe_kate?username=' + editlk + '&site=en.wikipedia.org', 'cnt'));
// To open the block page and block log simultaneously, replace the above line with:
// tabs.appendChild(addlilink('javascript:blockpage_and_log("' + editlk + '")', 'b'));
// and uncomment the blockpage_and_log() function above.
// add "blocklog" tab
//tabs.appendChild(addlilink('/w/index.php?title=Special%3ALog&type=block&user=&page=User%3A' + editlk, 'bl'));
}
// Add a "Kate" link to your monobook "personal menu" list at the very
// top of the page.
//
// Indicate where you would like "Kate" to appear:
// pt-userpage, pt-mytalk, pt-preferences,
// pt-watchlist, pt-mycontris, pt-logout
//
function addlilink2(tabs, url, name, id)
{
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
li.id = id;
li.appendChild(na);
tabs.appendChild(li);
return li;
}
function addPortletLink(portlet, href, text, id, tooltip, accesskey, nextnode) {
var node = document.getElementById(portlet);
if ( !node ) return null;
node = node.getElementsByTagName( "ul" )[0];
if ( !node ) return null;
var link = document.createElement( "a" );
link.appendChild( document.createTextNode( text ) );
link.href = href;
var item = document.createElement( "li" );
item.appendChild( link );
if ( id ) item.id = id;
if ( accesskey ) {
link.setAttribute( "accesskey", accesskey );
tooltip += " ["+accesskey+"]";
}
if ( tooltip ) {
link.setAttribute( "title", tooltip );
}
if ( accesskey && tooltip ) {
updateTooltipAccessKeys( new Array( link ) );
}
if ( nextnode && nextnode.parentNode == node )
node.insertBefore( item, nextnode );
else
node.appendChild( item ); // IE compatibility (?)
return item;
}
function addToolBoxLinks()
{
// use the "edit this page" tab to get user name
var user = document.getElementById('ca-edit').getElementsByTagName('ul')[0].href;
// cut everything up to "title=" from the start and everything past "&action=edit" from the end
user = user.substring(user.indexOf('title=') + 6, user.lastIndexOf('&action=edit'));
var url = 'http://countervandalism.org/Count.php?username=' + user + '&submit=Count';
var name = 'Count';
var id = 'toolbox_count';
//var tb = document.getElementById('p-navigation').getElementsByTagName('ul')[0];
addPortletLink('p-tb', url, name, id);
}
gsKateInsertBefore = 'pt-mycontris'; // leave blank to append after "logout"
function KateLink()
{
// use the "edit this page" tab to get user name
var user = document.getElementById('ca-edit').getElementsByTagName('ul')[0].href;
// cut everything up to "title=" from the start and everything past "&action=edit" from the end
user = user.substring(user.indexOf('title=') + 6, user.lastIndexOf('&action=edit'));
user = user.substring(user.indexOf(':') + 1);
var li = document.createElement( 'li' );
li.id = 'ca-editcount';
//not-working
//var a = document.createElement( 'a' );
//a.appendChild( document.createTextNode( 'count' ) ); // eh, the css makes the text lowercase
//a.href = 'http://tools.wikimedia.de/~interiot/cgi-bin/contribution_tree?user=' + user;
//working but changes to wikicode forces a change
//var a = document.createElement( 'a' );
//a.appendChild( document.createTextNode( 'count' ) ); // eh, the css makes the text lowercase
//a.href = 'http://en.wikipedia.org/wiki/User:Interiot/Tool2/code.js?username=' + user;
var a = document.createElement( 'a' );
a.appendChild( document.createTextNode( 'count' ) ); // eh, the css makes the text lowercase
a.href = 'http://countervandalism.org/Count.php?username=' + user + '&submit=Count';
li.appendChild( a );
a.appendChild(document.createTextNode('ec'));
y.appendChild(z);
document.getElementById('p-cactions').childNodes[3].childNodes[1].insertBefore(y,x.nextSibling);
//if ( ! gsKateInsertBefore ) // append to end (right) of list
//{
// document.getElementById( 'pt-logout' ).parentNode.appendChild( li );
//}
//else
//{
// var before = document.getElementById( gsKateInsertBefore );
// before.appendChild( li, before );
//}
}
// ***** Window Load ******
window.onload = Main;
function Main()
{
shortTabs();
add_tabs();
//add section 0 if not Editing a User talk page
if (document.title.indexOf("Editing User talk:") != 0)
addEditSection0();
//block tab on all user pages
if (document.title.indexOf("User") != -1)
add_block_tab();
//block ip stuff if on Block user page
if (document.title.indexOf("Block user") != -1)
do_blockip_stuff();
if (document.title.indexOf("User") != -1)
addToolBoxLinks(); //KateLink(); //count menu option on user pages
}
//basic user info auto-display
importScript("User:PleaseStand/userinfo.js");
// </nowiki>
// Filter changes live
// [[User:Lupin/recent2.js]] - please include this line
mw.loader.load(
'https://en.wikipedia.org/w/index.php?title=User:Lupin/recent2.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s');
//<nowiki> History tools
mw.loader.load(
'https://en.wikipedia.org/w/index.php?title=User:Voice_of_All/History/monobook.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s');
//</nowiki>[[Category:Wikipedians who use VoA script|{{PAGENAME}}]]