User:Isaac/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:Isaac/monobook.css. |
/* <pre><nowiki> */
/**
* Monobook scripts by Alphax and others
* Dual licensed under the GFDL and GPL
*/
/**** Twinkle ****/
importScript('User:AzaToth/twinkle.js');
/**** Add navigation popups ****/
//[[User:Lupin/popups.js]] - please include this line
importScript('User:Lupin/popups.js');
// customisations = see [[Wikipedia:Tools/Navigation popups]] for more
popupDelay = 0.7;
popupHideDelay = 0.3;
popupFixRedirs = true;
popupRedirAutoClick = 'wpPreview';
popupFixDabs = true;
popupStructure = 'menus';
/**** Lupin Edit Counter ****/
importScript('User:Lupin/editcount.js');
popupEditCounterTool='custom';
popupEditCounterUrl='http://en.wikipedia.org/wiki/User:$1?ectarget=$1';
/**** Live RC filter ****/
// [[User:Lupin/recent2.js]] - please include this line
importScript('User:Lupin/recent2.js');
/**** Initialise on window load and load custom functions ****/
$(function() {
addEditSection0();
changeLinks();
addToolBoxLinks();
googleSearch();
if (document.forms.editform)
{
mw.util.addPortletLink('p-cactions', 'javascript:wpTextboxReplace()', 'Replace', 'ca-replace',
'Regexp replace for the edit window', 'R', document.getElementById('ca-history'));
}
});
function wpTextboxReplace()
{
var s = prompt("Search regexp:");
if(s){
var r = prompt("Replace /"+s+"/ with:");
if(!r && r != '') return;
var txt = document.editform.wpTextbox1;
txt.value = txt.value.replace(new RegExp(s, "mg"), r);
}
}
function addEditSection0()
{
var x;
if (!(x = document.getElementById('ca-edit') )) return;
var url;
if (!(url = x.getElementsByTagName('a')[0] )) return;
if (!(url = url.href )) return;
var y = mw.util.addPortletLink('p-cactions', url+"§ion=0", '0', 'ca-edit-0',
'Edit the lead section of this page', '0', x.nextSibling);
y.className = x.className; // steal classes from the the edit tab...
x.className = 'istalk'; // ...and make the edit tab have no right margin
// exception: don't steal the "selected" class unless actually editing section 0:
if (/(^| )selected( |$)/.test(y.className)) {
if (!document.editform || !document.editform.wpSection
|| document.editform.wpSection.value != "0") {
y.className = y.className.replace(/(^| )selected( |$)/g, "$1");
x.className += ' selected';
}
}
}
/**** Make the top links look better ****/
function changeLinks()
{
if(!document.getElementById) return;
// remove the "my" bits
document.getElementById('pt-mytalk').firstChild.innerHTML = 'talk';
document.getElementById('pt-preferences').firstChild.innerHTML = 'preferences';
document.getElementById('pt-watchlist').firstChild.innerHTML = 'watchlist';
document.getElementById('pt-mycontris').firstChild.innerHTML = 'contributions';
}
/**** Add links to the toolbox ****/
function addToolBoxLinks()
{
var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
addlilink(tb, '/wiki/Wikipedia:Template_messages/User_talk_namespace', 'Talk messages', '');
addlilink(tb, '/wiki/Special:Newpages', 'New pages', '');
addlilink(tb, '/wiki/Special:Shortpages', 'Short pages', '');
addlilink(tb, '/wiki/Special:Log', 'Logs', '');
addlilink(tb, '/wiki/User:St.isaac/monobook.js', 'Monobook.js', '');
addlilink(tb, '/wiki/User:St.isaac/Sandbox', 'My sandbox', '');
addlilink(tb, '/wiki/WP:ICT', 'Image Copyright tags', '');
}
function addlilink(node, href, text, id, tooltip, accesskey) {
// the code below is mostly copied from mw.util.addPortletLink()
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 );
}
updateTooltipAccessKeys( new Array( link ) );
node.appendChild( item );
return item;
}
function googleSearch()
{
document.getElementById('searchform').action = 'http://www.google.com/search';
document.getElementById('searchInput').name = 'q';
document.getElementById('searchGoButton').name = 'btnG';
document.getElementById('mw-searchButton').name = 'btnI';
document.getElementById('searchGoButton').value = 'G';
document.getElementById('mw-searchButton').value = 'Lucky!';
var enwp = document.createElement('input');
enwp.id = 'as_sitesearch';
enwp.name = 'as_sitesearch';
enwp.value = 'en.wikipedia.org';
enwp.type = 'hidden';
document.getElementById('searchform').appendChild(enwp);
}
if (wgAction == 'history') //add a link to call histComb.js
$(function(){
var pagehis = document.getElementById('pagehistory');
if (!pagehis) return;
var lnk = document.createElement('a');
lnk.style.marginLeft = '10px';
lnk.href = '#';
lnk.appendChild(document.createTextNode('Improve…'));
lnk.onclick=function(){this.parentNode.removeChild(this);importScript('User:Alex_Smotrov/histcomb.js')}
pagehis.parentNode.insertBefore(lnk, pagehis);
})
/* </nowiki></pre> */