User:ABCD/monobook.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.
/* <nowiki> */ function aol(){ var form = document.editform; var txt = form.wpTextbox1; txt.value = "{{AOL}}\n\n" + txt.value; form.wpSummary.value = "{{[[Template:AOL|AOL]]}}" form.wpMinoredit.checked = true; } function closeafd(bold, notbold){ var form = document.editform; var txt = form.wpTextbox1; txt.value = "{{subst:at}} '''" + bold + "'''" + notbold + ". ~~~~\n" + txt.value + "\n{{subst:ab}}\n"; form.wpSummary.value = "close discussion: " + bold + notbold; form.wpWatchthis.checked = false; } function fixformat(){ var replacements = [ [/<\/?(b|strong)>/gi, "'''"], [/<\/?(i|em|var)>/gi, "''"], [/\{\{([Ss]u[bp])\|([^}]+)\}\}/g, "{{subst:$1|$2}}"], [/<\/div +>/gi, "</div>"], [/¡/g, "¡"], [/¢/g, "¢"], [/£/g, "£"], [/¤/g, "¤"], [/¥/g, "¥"], [/¦/g, "¦"], [/§/g, "§"], [/¨/g, "¨"], [/©/g, "©"], [/ª/g, "ª"], [/«/g, "«"], [/¬/g, "¬"], [/®/g, "®"], [/¯/g, "¯"], [/°/g, "°"], [/±/g, "±"], [/²/g, "²"], [/³/g, "³"], [/´/g, "´"], [/µ/g, "µ"], [/¶/g, "¶"], [/·/g, "·"], [/¸/g, "¸"], [/¹/g, "¹"], [/º/g, "º"], [/»/g, "»"], [/¼/g, "¼"], [/½/g, "½"], [/¾/g, "¾"], [/¿/g, "¿"], [/À/g, "À"], [/Á/g, "Á"], [/Â/g, "Â"], [/Ã/g, "Ã"], [/Ä/g, "Ä"], [/Å/g, "Å"], [/Æ/g, "Æ"], [/Ç/g, "Ç"], [/È/g, "È"], [/É/g, "É"], [/Ê/g, "Ê"], [/Ë/g, "Ë"], [/Ì/g, "Ì"], [/Í/g, "Í"], [/Î/g, "Î"], [/Ï/g, "Ï"], [/Ð/g, "Ð"], [/Ñ/g, "Ñ"], [/Ò/g, "Ò"], [/Ó/g, "Ó"], [/Ô/g, "Ô"], [/Õ/g, "Õ"], [/Ö/g, "Ö"], [/×/g, "×"], [/Ø/g, "Ø"], [/Ù/g, "Ù"], [/Ú/g, "Ú"], [/Û/g, "Û"], [/Ü/g, "Ü"], [/Ý/g, "Ý"], [/Þ/g, "Þ"], [/ß/g, "ß"], [/à/g, "à"], [/á/g, "á"], [/â/g, "â"], [/ã/g, "ã"], [/ä/g, "ä"], [/å/g, "å"], [/æ/g, "æ"], [/ç/g, "ç"], [/è/g, "è"], [/é/g, "é"], [/ê/g, "ê"], [/ë/g, "ë"], [/ì/g, "ì"], [/í/g, "í"], [/î/g, "î"], [/ï/g, "ï"], [/ð/g, "ð"], [/ñ/g, "ñ"], [/ò/g, "ò"], [/ó/g, "ó"], [/ô/g, "ô"], [/õ/g, "õ"], [/ö/g, "ö"], [/÷/g, "÷"], [/ø/g, "ø"], [/ù/g, "ù"], [/ú/g, "ú"], [/û/g, "û"], [/ü/g, "ü"], [/ý/g, "ý"], [/þ/g, "þ"], [/ÿ/g, "ÿ"], [/ƒ/g, "ƒ"], [/Α/g, "Α"], [/Β/g, "Β"], [/Γ/g, "Γ"], [/Δ/g, "Δ"], [/Ε/g, "Ε"], [/Ζ/g, "Ζ"], [/Η/g, "Η"], [/Θ/g, "Θ"], [/Ι/g, "Ι"], [/Κ/g, "Κ"], [/Λ/g, "Λ"], [/Μ/g, "Μ"], [/Ν/g, "Ν"], [/Ξ/g, "Ξ"], [/Ο/g, "Ο"], [/Π/g, "Π"], [/Ρ/g, "Ρ"], [/Σ/g, "Σ"], [/Τ/g, "Τ"], [/Υ/g, "Υ"], [/Φ/g, "Φ"], [/Χ/g, "Χ"], [/Ψ/g, "Ψ"], [/Ω/g, "Ω"], [/α/g, "α"], [/β/g, "β"], [/γ/g, "γ"], [/δ/g, "δ"], [/ε/g, "ε"], [/ζ/g, "ζ"], [/η/g, "η"], [/θ/g, "θ"], [/ι/g, "ι"], [/κ/g, "κ"], [/λ/g, "λ"], [/μ/g, "μ"], [/ν/g, "ν"], [/ξ/g, "ξ"], [/ο/g, "ο"], [/π/g, "π"], [/ρ/g, "ρ"], [/ς/g, "ς"], [/σ/g, "σ"], [/τ/g, "τ"], [/υ/g, "υ"], [/φ/g, "φ"], [/χ/g, "χ"], [/ψ/g, "ψ"], [/ω/g, "ω"], [/ϑ/g, "ϑ"], [/ϒ/g, "ϒ"], [/ϖ/g, "ϖ"], [/•/g, "•"], [/…/g, "…"], [/′/g, "′"], [/″/g, "″"], [/‾/g, "‾"], [/⁄/g, "⁄"], [/℘/g, "℘"], [/ℑ/g, "ℑ"], [/ℜ/g, "ℜ"], [/™/g, "™"], [/ℵ/g, "ℵ"], [/←/g, "←"], [/↑/g, "↑"], [/→/g, "→"], [/↓/g, "↓"], [/↔/g, "↔"], [/↵/g, "↵"], [/⇐/g, "⇐"], [/⇑/g, "⇑"], [/⇒/g, "⇒"], [/⇓/g, "⇓"], [/⇔/g, "⇔"], [/∀/g, "∀"], [/∂/g, "∂"], [/∃/g, "∃"], [/∅/g, "∅"], [/∇/g, "∇"], [/∈/g, "∈"], [/∉/g, "∉"], [/∋/g, "∋"], [/∏/g, "∏"], [/∑/g, "∑"], [/∗/g, "∗"], [/√/g, "√"], [/∝/g, "∝"], [/∞/g, "∞"], [/∠/g, "∠"], [/∧/g, "∧"], [/∨/g, "∨"], [/∩/g, "∩"], [/∪/g, "∪"], [/∫/g, "∫"], [/∴/g, "∴"], [/∼/g, "∼"], [/≅/g, "≅"], [/≈/g, "≈"], [/≠/g, "≠"], [/≡/g, "≡"], [/≤/g, "≤"], [/≥/g, "≥"], [/⊂/g, "⊂"], [/⊃/g, "⊃"], [/⊄/g, "⊄"], [/⊆/g, "⊆"], [/⊇/g, "⊇"], [/⊕/g, "⊕"], [/⊗/g, "⊗"], [/⊥/g, "⊥"], [/⋅/g, "⋅"], [/⌈/g, "⌈"], [/⌉/g, "⌉"], [/⌊/g, "⌊"], [/⌋/g, "⌋"], [/⟨/g, "〈"], [/⟩/g, "〉"], [/◊/g, "◊"], [/♠/g, "♠"], [/♣/g, "♣"], [/♥/g, "♥"], [/♦/g, "♦"], [/Œ/g, "Œ"], [/œ/g, "œ"], [/Š/g, "Š"], [/š/g, "š"], [/Ÿ/g, "Ÿ"], [/ˆ/g, "ˆ"], [/˜/g, "˜"], [/‘/g, "‘"], [/’/g, "’"], [/‚/g, "‚"], [/“/g, "“"], [/”/g, "”"], [/„/g, "„"], [/†/g, "†"], [/‡/g, "‡"], [/‰/g, "‰"], [/‹/g, "‹"], [/›/g, "›"], [/€/g, "€"], [/\{\{SERVER\}\}\{\{localurl:/g, "{{fullurl:"], [/\{\{NAMESPACE\}\}:\{\{PAGENAME\}\}/g, "{{FULLPAGENAME}}"] ]; var form = document.editform; var txt = form.wpTextbox1; var val = txt.value; for(var i in replacements) val = val.replace(replacements[i][0], replacements[i][1]); txt.value = val; form.wpSummary.value += "formatting"; form.wpMinoredit.checked = true; } function replace(){ var s = prompt("Search regexp?"); if(s){ var r = prompt("Replace regexp?"); if(!r && r != '') return; var txt = document.editform.wpTextbox1; txt.value = txt.value.replace(new RegExp(s, "g"), r); } } function afdresult(){ var res = prompt("Result?"); if(!res) return; var form = document.editform; form.wpSummary.value = 'AFD result'; var txt = form.wpTextbox1; txt.value += '{{oldafdfull|date=[[DAY MONTH]] [[2006]]|result=' + res + '|votepage={{subst:PAGENAME}}}}'; txt.focus(); } function test(x){ var form = document.editform; var txt = form.wpTextbox1; if(txt.value.length > 0) txt.value += '\n'; txt.value += '{{subst:test' + (x == 1 ? '' : x) + '}} ~~~~'; var s = ''; switch(x){ case 1: s = 'Thanks for your test'; break; case 2: case 3: s = 'Please stop'; break; case 4: s = 'Last warning'; break; case 5: s = 'You have been blocked'; break; } form.wpSummary.value = s; } function hideafd(){ var divs = document.getElementsByTagName("div"); for(var x = 0; x < divs.length; ++x) if(divs[x].className.indexOf("vfd") != -1 || divs[x].className.indexOf("afd") != -1) divs[x].style.display = "none"; document.getElementById('footer').style.display = 'none'; } function showafd(){ var divs = document.getElementsByTagName("div"); for(var x = 0; x < divs.length; ++x) if(divs[x].className.indexOf("vfd") != -1 || divs[x].className.indexOf("afd") != -1) divs[x].style.display = ""; document.getElementById('footer').style.display = ''; } function addlilink(tabs, url, name, id, title, key){ var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); na.accesskey = key; var pref = 'alt-'; var clientPC = navigator.userAgent.toLowerCase(); if(((clientPC.indexOf('AppleWebKit')!=-1) && (clientPC.indexOf('spoofer')==-1)) || navigator.userAgent.toLowerCase().indexOf( 'mac' ) != -1 ) pref = 'control-'; if(clientPC.indexOf('opera')!=-1) pref = 'shift-esc-'; if(key && title) na.title = title + ' [' + pref + key + ']'; else if(title) na.title = title; else if(key) na.title = '[' + pref + key + ']'; var li = document.createElement('li'); if(id) li.id = id; li.appendChild(na); tabs.appendChild(li); return li; } function addTab(url, name, id, title, key){ var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; addlilink(tabs, url, name, id, title, key); } function addPurge(){ var x = document.getElementById('ca-history'); if(!x) return; if(x.children) x = x.children[0].href; else x = x.childNodes[0].href; addTab(x.replace(/=history/, "=purge"), 'purge', 'ca-purge', 'Purge the internal cache for this page', 'g'); } function addEditSection0(){ if(!document.getElementById) return; var x = document.getElementById('ca-edit'); if(!x) return; var 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'; } var 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); } z.title = 'Edit the zeroth section of this page'; akeytt(); } function changeLinks(){ if(!document.getElementById) return; 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'; document.getElementById('pt-logout').firstChild.innerHTML = 'Log out'; if(document.getElementById('ca-talk')) document.getElementById('ca-talk').firstChild.innerHTML = 'Talk'; if(document.getElementById('ca-edit')) document.getElementById('ca-edit').firstChild.innerHTML = 'Edit'; if(document.getElementById('ca-nstab-wp')) document.getElementById('ca-nstab-wp').firstChild.innerHTML = 'About'; } function addForceSummary(){ if(!/&action=edit/.test(window.location.href)) return; if(/§ion=new/.test(window.location.href)) return; if(!document.forms.editform) return; document.forms.editform.wpSave.onclick = forceSummary; } function forceSummary(){ var form = document.forms.editform; if(!form.wpSummary.value.replace(/^(\/\*.*\*\/)? *(.*) *$/,'$2')){ var r = prompt('Are you sure you want to submit without adding a summary?\nTo add a summary, type it in the box below:',form.wpSummary.value); if(r == null) return false; form.wpSummary.value = r; } return true; } function afddelete(){ document.forms.deleteconfirm.wpReason.value = '[[Wikipedia:Articles for deletion/' + unescape(window.location.href.replace(/^.*\?title=([^&]+)&action=delete.*$/, '$1').replace(/_/g, ' ')).replace(/^Talk:/, '') + ']]'; } function morelinks(){ if(/^Editing Wikipedia:(Articles|Votes|Pages) for deletion/.test(document.title)){ addTab('javascript:closeafd("keep", "")', 'K'); addTab('javascript:closeafd("merge and redirect", " to [[" + prompt("Merge and redirect to?") + "]]")', 'M&R'); addTab('javascript:closeafd("redirect", " to [[" + prompt("Redirect to?") + "]]")', 'R'); addTab('javascript:closeafd("transwiki", " to " + prompt("Transwiki to?"))', 'T'); addTab('javascript:closeafd("transwiki", " to Wiktionary")', 'WIKT'); addTab('javascript:closeafd("speedy delete", "")', 'SD'); addTab('javascript:closeafd("delete", "")', 'D'); addTab('javascript:closeafd(prompt("Result?"), "")', 'Oth'); }else if(document.title.indexOf("Editing User talk:") == 0){ addTab('javascript:replace()', 'Replace'); addTab('javascript:fixformat()', 'Format'); addTab('javascript:test(1)', 'Test'); addTab('javascript:test(2)', '2'); addTab('javascript:test(3)', '3'); addTab('javascript:test(4)', '4'); addTab('javascript:test(5)', '5'); addTab('javascript:aol()', 'AOL'); }else if(document.title.indexOf("Editing ") == 0){ addTab('javascript:replace()', 'Replace'); addTab('javascript:fixformat()', 'Format'); addTab('javascript:afdresult()', 'AFD'); }else if(document.title.indexOf("Confirm delete") == 0){ addTab('javascript:afddelete()', 'AFD'); }else if(/^Wikipedia:(Articles|Votes|Pages) for deletion/.test(document.title)){ addTab('javascript:hideafd()', 'Hide', 'ca-hide'); addTab('javascript:showafd()', 'Show', 'ca-show'); } } function addToolBoxLinks(){ var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; addlilink(tb, '/wiki/Special:Newpages', 'New pages', 't-newpages'); addlilink(tb, '/wiki/Special:Shortpages', 'Short pages', 't-shortpages'); } function strip_namespace(target){ var colon = target.indexOf(':'); if(colon != -1){ var spaces = ['User', 'Wikipedia', 'Image', 'MediaWiki', 'Template', 'Help', 'Category', 'Portal']; var ns = target.substring(0, colon); if(ns == '' || ns == 'Talk') return target.substring(colon + 1); else for(var i = 0; i < spaces.length; ++i) if(ns == spaces[i] || ns == spaces[i] + '_talk') return target.substring(colon + 1); } return target; } // Adds a "blocklog" tab and fills in the username field on Special:Blockip, if a "&ip=username" is present. function do_blockip_stuff(){ var form = document.getElementById('blockip'); // focus on Reason field form.wpBlockReason.focus(); var target = getParam('ip'); if(target == '') return; // add "blocklog" tab addTab('/wiki/Special:Log/block?page=User:' + target, 'blocklog', 'ca-blocklog'); } // Adds "block" and "blocklog" tabs to User: and User talk: pages. function add_block_tab(){ var c1 = document.getElementById('column-one'); var tabs = document.getElementById('p-cactions').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 addTab('/wiki/Special:Blockip/' + editlk, 'block', 'ca-block'); // add "blocklog" tab addTab('/wiki/Special:Log/block?page=User:' + editlk, 'blocklog', 'ca-blocklog'); } function blockip() { if(document.title.indexOf('User:') == 0 || document.title.indexOf('User talk:') == 0) add_block_tab(); else if(document.title.indexOf('Block user') == 0) // could stand to be more robust do_blockip_stuff(); } function getParam(name){ if(location.search){ for(var x in location.search.substring(1).split('&')){ var eq = x.indexOf('='); if(x.substring(0, eq) == name) return x.substring(eq + 1); } } return ''; } function myLoadFuncs(){ addPurge(); addEditSection0(); changeLinks(); addForceSummary(); morelinks(); addToolBoxLinks(); blockip(); } if (window.addEventListener) window.addEventListener("load",myLoadFuncs,false); else if (window.attachEvent) window.attachEvent("onload",myLoadFuncs); //-------------------------------------------------------------------------------- // </nowiki>[[User:Lupin/popups.js]]<nowiki> - 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>'); popupAdminLinks=true; popupActionsMenu=false; popupImages=false; popupPreviewRawTemplates=true; /* </nowiki> */