Участник:EvilCat/monobook.js
< Участник:EvilCat
Версия от 11:41, 5 марта 2012; EvilCat (обсуждение)
function addGodButton() { var toolbar = document.getElementById('toolbar') if (!toolbar) return var i = document.createElement('span') i.innerHTML='[Б]' i.onclick = god i.style.cursor = 'pointer' toolbar.appendChild(i) } addOnloadHook(addGodButton) function god () { var txt='', hidden = [], wpTextbox1 = document.editform.wpTextbox1 var winScroll = document.documentElement.scrollTop try {txt='ая'.replace(/а/g,'б').replace(/б(?=я)/,'в')} catch(e){}//check regexp support if (txt != 'вя' || (navigator.appName=='Netscape' && navigator.appVersion.substr (0, 1) < 5)) { alert(wmCantWork); return } wpTextbox1.focus() if (typeof wpTextbox1.selectionStart != 'undefined' && (navigator.productSub > 20031000 || is_safari || is_opera)) { //Mozilla/Opera/Safari3 var textScroll = wpTextbox1.scrollTop var startPos = wpTextbox1.selectionStart var endPos = wpTextbox1.selectionEnd txt = wpTextbox1.value.substring(startPos, endPos) if (txt == '') processAllText() else{ processText() wpTextbox1.value = wpTextbox1.value.substring(0, startPos) + txt + wpTextbox1.value.substring(endPos) } wpTextbox1.selectionStart = startPos wpTextbox1.selectionEnd = startPos + txt.length wpTextbox1.scrollTop = textScroll }else if (document.selection && document.selection.createRange) { //IE var range = document.selection.createRange() txt = range.text if (txt == '') processAllText() else{ processText() range.text = txt if (range.moveStart) range.moveStart('character', - txt.length) range.select() } }else // other browsers if (confirm(wmFullText)) processAllText() document.documentElement.scrollTop = winScroll // scroll back, for IE/Opera //functions function processAllText(){ txt = wpTextbox1.value if (txt=='version') alert('Викификатор '+wmVersion) processText() r(/^[\n\r]+/, '') wpTextbox1.value = txt txt = '' if (window.auto_comment && window.insertSummary && !document.editform.wpSection.value) insertSummary('викификатор') } function processText(){ var u = ' ' //messed by RK if (wgNamespaceNumber % 2 || wgNamespaceNumber==4) { //is talk page var sigs = txt.match(/\d\d:\d\d, \d\d? \S{3,8} 20\d\d \(UTC\)/g) if (sigs && sigs.length > 1) { alert(wmTalkPage); return } } hideTag('nowiki') hideTag('pre') hideTag('source') hideTag('code') hideTag('tt') hideTag('math') r(/( |\n|\r)+\{\{(·|•|\*)\}\}/g, '{{$2}}'); //before {{·/•/*}}, usually in templates hide(/{\{[\s\S]+?}}/g)//templates hide(/^ .*/mg) hide(/(https?|ftp|news|nntp|telnet|irc|gopher):\/\/[^\s\[\]<>"]+ ?/gi) hide(/^#(redirect|перенапр(авление)?)/i) hideTag('gallery') r(/ +(\n|\r)/g,'$1')//spaces at EOL txt = '\n'+txt+'\n' r(/\{\{Божество([\s\r\n]+)\|/, '{{Божество D&D/d20$1\|') function r(r1, r2){ txt = txt.replace(r1, r2) } }