User:Rune.welsh/monobook.js
From Wikipedia, the free encyclopedia
If a message on your talk page led you here, please be wary of who left it. The code below could contain malicious content capable of compromising your account; if your account appears to be compromised, it will be blocked. If you are unsure whether the code is safe, you can ask at the appropriate village pump.
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.
/////////////////////////////////////////////////////////////////////// ///// Add LI Link ///////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// function addlilink(tabs, url, name, id, title, key){ var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); if(id) li.id = id; li.appendChild(na); tabs.appendChild(li); if(id) { if(key && title) { ta[id] = [key, title]; } else if(key) { ta[id] = [key, '']; } else if(title) { ta[id] = ['', title]; } } // re-render the title and accesskeys from existing code in wikibits.js akeytt(); return li; } /////////////////////////////////////////////////////////////////////// ///// Add Tab ///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// function addTab(url, name, id, title, key){ var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; return addlilink(tabs, url, name, id, title, key); } /////////////////////////////////////////////////////////////////////// ///// Tabs //////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// //Please leave the following line //user:Where/usertabs addOnloadHook(function() { if (document.title.search("/") != -1 || document.title.search("- History -") != -1) { //no subpages or history return; } if (document.title.indexOf("User:") == 0 || document.title.indexOf("User talk:") == 0) { username_a = document.URL.match(/:.*:(.*)/); username=username_a[1]; addTab("http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=move&user=" + username, "Moves", "ca-pagemoves", "page moves", ""); addTab("http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=block&page=User:" + username, "Block log", "ca-blog", "blog", ""); } }); /////////////////////////////////////////////////////////////////////// // Add "edit section 0" /////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// function addEditSection0() { ta['ca-edit-0'] = ['', 'Edit the zeroth section of this page']; if (!document.getElementById) return; x = document.getElementById('ca-edit'); if(!x) return; y = document.createElement('LI'); y.id = 'ca-edit-0'; if (x.className == 'selected') { if (/&action=edit§ion=0$/.test(window.location.href)) { x.className = 'istalk'; y.className = 'selected'; } else { x.className = 'selected istalk'; } } else if (x.className == 'selected istalk') { if (/&action=edit§ion=0$/.test(window.location.href)) { x.className = 'istalk'; y.className = 'selected istalk'; } else { y.className = 'istalk'; } } else { y.className = x.className; x.className = 'istalk'; } z = document.createElement('A'); if (x.children) { z.href = x.children[0].href + '§ion=0'; z.appendChild(document.createTextNode('0')); y.appendChild(z); document.getElementById('p-cactions').children[1].insertBefore(y,x.nextSibling); } else { z.href = x.childNodes[0].href + '§ion=0'; z.appendChild(document.createTextNode('0')); y.appendChild(z); document.getElementById('p-cactions').childNodes[3].insertBefore(y,x.nextSibling); } } if (document.title.indexOf("Editing ") == -1) { if (window.addEventListener) window.addEventListener("load", addEditSection0, false); else if (window.attachEvent) window.attachEvent("onload", addEditSection0); } /////////////////////////////////////////////////////////////////////// // POP-UPS! /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // [[User:Lupin/popups.js]] - please include this line document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); popupFixRedirs=true; popupFixDabs=true; popupAdminLinks=true; popupDragging=true; imagePopupsForImages=false; popupPreviewKillTemplates=true; /////////////////////////////////////////////////////////////////////// // Interiot's edit counter //////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); /////////////////////////////////////////////////////////////////////// // Show last diff ///////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // addLastDiff addOnloadHook(function () { z=document.getElementById("content").childNodes; for (var n=0;n<z.length;n++) { if (z[n].className=="firstHeading") { var pname=z[n].textContent; } } var l=addTab("http://en.wikipedia.org/w/index.php?title=" + pname + "&diff=cur&oldid=prev", 'Last diff', ''); l.lastChild.title="Show most recent diff"; }); /////////////////////////////////////////////////////////////////////// // Diff fixer ///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // inline style sheet to keep this whole thing self-contained: document.write('<style type="text/css">' + ' .xdiff { width: 100%; background: white; }' + ' .xdiff-row { width: 100%; margin: 0 0 3px 0; overflow: hidden; }' + ' .xdiff-col { width: 49%; margin: 0; float: left; clear: none; position: relative; }' + ' .xdiff-sign, .xdiff-outer, .xdiff-inner { display: block; margin: 0; }' + ' .xdiff-sign { position: absolute; top: 0; left: 0; width: 2em; text-align: center; }' + ' .xdiff-outer { padding: 0 0 0 2em; }' + ' .xdiff-inner { overflow: auto; overflow-y: visible; width: 100%; }' + ' .xdiff-inner.diff-addedline { font-size: 85%; background: #cfc; }' + ' .xdiff-inner.diff-deletedline { font-size: 85%; background: #ffa; }' + ' .xdiff-inner.diff-context { font-size: 85%; background: #eee; }' + (!document.recalc ? '' : // IE kluge: ' * html .xdiff-inner { padding-bottom: expression(this.scrollWidth > this.offsetWidth ? "16px" : 0); }' + ' * html .xdiff-sign { top: expression((this.parentNode.clientHeight - this.offsetHeight)/2 + "px"); }') + '<'+'/style>'); if (false) addOnloadHook(function () { // OBSOLETE!!! var diffSigns = new Array(); var fixDiffWidth = function () { var tables = document.getElementsByTagName('table'); for (var i = 0; i < tables.length; i++) { if (tables[i].className != 'diff') continue; var rows = tables[i].getElementsByTagName('tr'); var diffDiv = document.createElement('div'); diffDiv.className = 'xdiff'; for (var j = 0; j < rows.length; j++) { var rowDiv = document.createElement('div'); rowDiv.className = 'xdiff-row'; var colDiv = null; var cols = rows[j].getElementsByTagName('td'); for (var k = 0; k < cols.length; k++) { if (!colDiv) { colDiv = document.createElement('div'); colDiv.className = 'xdiff-col'; rowDiv.appendChild(colDiv); } if (cols[k].getAttribute('colspan') == 2 || cols[k].className.substring(0,5) == 'diff-') { // use spans instead of divs so that an eventual non-js solution will look nice in lynx! var outerSpan = document.createElement('span'); var innerSpan = document.createElement('span'); outerSpan.className = 'xdiff-outer'; innerSpan.className = 'xdiff-inner ' + cols[k].className; innerSpan.style.textAlign = cols[k].getAttribute('align'); for (var node = cols[k].firstChild; node; node = node.nextSibling) innerSpan.appendChild(node.cloneNode(true)); innerSpan.appendChild(document.createTextNode(String.fromCharCode(0xa0))); // add nbsp outerSpan.appendChild(innerSpan); colDiv.appendChild(outerSpan); colDiv = null; // start new column } else if (cols[k].firstChild && (cols[k].firstChild.nextSibling || cols[k].firstChild.nodeType != 3 || cols[k].firstChild.nodeValue.match(/\S/))) { // use spans instead of divs so that an eventual non-js solution will look nice in lynx! var signSpan = document.createElement('span'); signSpan.className = 'xdiff-sign'; if (!signSpan.style.setExpression) diffSigns[diffSigns.length] = signSpan; for (var node = cols[k].firstChild; node; node = node.nextSibling) signSpan.appendChild(node.cloneNode(true)); colDiv.appendChild(signSpan); } } diffDiv.appendChild(rowDiv); } tables[i].parentNode.replaceChild(diffDiv, tables[i]); } }; // finally, a kluge to vertically center the +/- signs var centerDiffSigns = function () { for (var i = 0; i < diffSigns.length; i++) { var parentHeight; if (!( parentHeight = diffSigns[i].parentNode )) continue; if (!( parentHeight = parentHeight.clientHeight )) continue; diffSigns[i].style.top = ((parentHeight - diffSigns[i].offsetHeight)/2) + "px"; } }; fixDiffWidth(); if (diffSigns.length) { hookEvent('resize', centerDiffSigns); setTimeout(centerDiffSigns, 250); } }); //

