User:Pelote de laine/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 can be added at User:Pelote de laine/monobook.css. |
//<source lang="JavaScript">
/** Change Special:Search to use a drop-down menu *******************************************************
*
* Description: Change Special:Search to use a drop-down menu, with the default being
* the internal MediaWiki engine
* Created and maintained by: [[User:Gracenotes]]
*/
addOnloadHook( SpecialSearchEnhanced )
function SpecialSearchEnhanced() {
if( wgCanonicalNamespace != "Special" || wgCanonicalSpecialPageName != "Search" ) {
return
}
var createOption = function(site, action, mainQ, addQ, addV) {
var opt = document.createElement('option');
opt.appendChild(document.createTextNode(site));
searchEngines.push([action, mainQ, addQ, addV]);
return opt;
}
if (document.forms['powersearch']) {
var searchForm = document.forms['powersearch'];
alert('search 1a')
} else if (document.forms['search']) {
var searchForm = document.forms['search'];
alert('search 1b')
} else {
alert('search 1c')
}
if (searchForm.lsearchbox) {
var searchBox = searchForm.lsearchbox;
alert( '2a' )
} else {
var searchBox = searchForm.search;
alert( '2b' + searchBox )
}
var selectBox = document.createElement('select');
selectBox.id = 'searchEngine';
searchForm.onsubmit = function() {
var optSelected = searchEngines[document.getElementById('searchEngine').selectedIndex];
searchForm.action = optSelected[0];
searchBox.name = optSelected[1];
searchForm.title.value = optSelected[3];
searchForm.title.name = optSelected[2];
}
selectBox.appendChild(createOption('MediaWiki search', wgScriptPath + '/index.php', 'search', 'title', 'Special:Search'));
selectBox.appendChild(createOption('Google', 'http://www.google.com/search', 'q', 'sitesearch', 'en.wikipedia.org'));
selectBox.appendChild(createOption('Yahoo', 'http://search.yahoo.com/search', 'p', 'vs', 'en.wikipedia.org'));
selectBox.appendChild(createOption('Windows Live', 'http://search.live.com/results.aspx', 'q', 'q1', 'site:http://en.wikipedia.org'));
selectBox.appendChild(createOption('Wikiwix', 'http://www.wikiwix.com/', 'action', 'lang', 'en'));
selectBox.appendChild(createOption('Exalead', 'http://www.exalead.com/wikipedia/results', 'q', 'language', 'en'));
searchBox.style.marginLeft = '0px';
if (document.getElementById('loadStatus')) {
var lStat = document.getElementById('loadStatus');
} else {
var lStat = searchForm.fulltext;
}
lStat.parentNode.insertBefore(selectBox, lStat);
}
var searchEngines = [];
addOnloadHook(SpecialSearchEnhanced);
//</source>