User:The-Q/monobook.js
From Wikipedia, the free encyclopedia
If a message on your talk page led you here, please be wary of who left it. Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. If this is a .js page, the code will be executed when previewing the page.
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
if (wgAction == 'history') //add a link to call histComb.js addOnloadHook(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); }) // Adds a drop-down menu to the search box to choose the namespace to search in. addOnloadHook(function () { var searchGoButton = document.getElementById('searchGoButton'); if (!searchGoButton) return; var searchNsHidden = document.createElement('input'); searchNsHidden.id = 'searchNsHidden'; searchNsHidden.type = 'hidden'; searchNsHidden.name = 'ns0'; searchNsHidden.value = '1'; var searchNsMenu = document.createElement('select'); searchNsMenu.id = 'searchNsMenu'; searchNsMenu.name = 'ns'; searchNsMenu.options[searchNsMenu.options.length] = new Option('(Main)', 0); searchNsMenu.options[searchNsMenu.options.length] = new Option('Talk', 1); searchNsMenu.options[searchNsMenu.options.length] = new Option('User', 2); searchNsMenu.options[searchNsMenu.options.length] = new Option('User talk', 3); searchNsMenu.options[searchNsMenu.options.length] = new Option('Wikipedia', 4); searchNsMenu.options[searchNsMenu.options.length] = new Option('Wikipedia talk', 5); searchNsMenu.options[searchNsMenu.options.length] = new Option('Image', 6); searchNsMenu.options[searchNsMenu.options.length] = new Option('Image talk', 7); searchNsMenu.options[searchNsMenu.options.length] = new Option('MediaWiki', 8); searchNsMenu.options[searchNsMenu.options.length] = new Option('MediaWiki talk', 9); searchNsMenu.options[searchNsMenu.options.length] = new Option('Template', 10); searchNsMenu.options[searchNsMenu.options.length] = new Option('Template talk', 11); searchNsMenu.options[searchNsMenu.options.length] = new Option('Help', 12); searchNsMenu.options[searchNsMenu.options.length] = new Option('Help talk', 13); searchNsMenu.options[searchNsMenu.options.length] = new Option('Category', 14); searchNsMenu.options[searchNsMenu.options.length] = new Option('Category talk', 15); searchNsMenu.options[searchNsMenu.options.length] = new Option('Portal', 100); searchNsMenu.options[searchNsMenu.options.length] = new Option('Portal talk', 101); searchNsMenu.onchange = function () { searchNsHidden.name = 'ns' + (this.selectedIndex < 0 ? '0' : this.options[this.selectedIndex].value); }; // From /skins-1.5/monobook/main.css?5: searchNsMenu.style.width = '10.9em'; searchNsMenu.style.margin = '0'; searchNsMenu.style.fontSize = '95%'; searchGoButton.parentNode.insertBefore(searchNsHidden, searchGoButton); searchGoButton.parentNode.insertBefore(searchNsMenu, searchGoButton); }); //<source lang="javascript"> addOnloadHook(function(){ if (location.href.indexOf('Special:Watchlist') == -1) return; //Are we on a watchlist? //days = document.getElementById('bodyContent').getElementsByTagName('ul'); days = document.evaluate( //Hell knows how it works - found in "Dive into Greasemonkey" "//ul[@class='special']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); for (d = 0; d < days.snapshotLength; d++) { //For each day day = days.snapshotItem(d); newday = document.createElement('ul'); //This will replace the old listing while ((diffs = day.getElementsByTagName('li')).length > 0) { //Are there any diffs left? //Try to extract the namespace As = diffs[0].getElementsByTagName('a'); if (As[0].innerHTML == 'diff') pagename = As[2].innerHTML; else pagename = As[1].innerHTML; if (pagename.indexOf(':') == -1) namespace = 'Main'; else namespace = pagename.split(':')[0]; //This will fail for articles which contain ":" in name hdrs = newday.getElementsByTagName('h5'); //Get the list of namespace headers hdr = null; for (j=0; j<hdrs.length; j++) //Find the header if (hdrs[j].innerHTML==namespace) { hdr = hdrs[j]; break; } if (hdr==null) { //Not found? Make a new one! hdr = document.createElement('h5'); hdr.innerHTML = namespace; newday.appendChild(hdr); namespacesub = document.createElement('ul'); namespacesub.className = "special"; newday.appendChild(namespacesub); } hdr.nextSibling.appendChild(diffs[0]); //Move the diff } newday.appendChild(document.createElement('hr')); //For readablility day.parentNode.replaceChild(newday,day); } }); //</source>[[Category:Wikipedia scripts|watchlistSorter]] // [[User:Ais523/topcontrib.js]] // This script color-codes lines according to who has the top contribution for a page. //<pre><nowiki> addOnloadHook(function () { if((location.href.indexOf("Special:Contributions")!=-1|| location.href.indexOf("Special%3AContributions")!=-1) &&location.href.indexOf("&The-Q")==-1&&location.href.indexOf("?The-Q")==-1) { var i,li,a; li=document.getElementById("bodyContent"); //li.getElementsByTagName("ul")[0].tagName="ol"; li=li.getElementsByTagName("li"); i=-1; a=new Array(); while(++i<li.length) { var s,t; t=li[i].innerHTML.match(/"\/wiki\/([^"]*)"/)[1]; if(li[i].getElementsByTagName("strong").length>0) s="#EEEEFF"; else s="#FFEEEE"; if(a[t]!=undefined) s=(a[t]=="#EEEEFF"?"#EEFFFF":"#FFFFEE"); else a[t]=s; li[i].innerHTML="<SPAN STYLE='background-color:"+s+"'>"+li[i].innerHTML+"</SPAN>"; } } }); //</nowiki></pre> //[[Category:Wikipedia scripts]]