User:Xenophon (bot)/monobook.js

/* */ /** * User:Bookofjude's monobook.js, based on primarily on User:Wayward's,  * which in turn is based on User:Alphax/monobook.js's * with many of User:Wayward's own mods * Must use User:Wayward/monobook.css for full tab functionality * Forked from User:ABCD/monobook.js around April 2005 * Dual licensed under the GFDL and GPL * See also: User:JesseW/monobook.js * And best of all: WP:US **/ $(function {	if(document.forms.editform) {		var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];		addlilink(tabs, 'javascript:softRedirect;', 'Soft redirect', 'ca-redirect');	} });

$(function {   if(queryString("submitmove")=="true") document.forms[0].wpMove.click    if(queryString("submitdelete")=="true") document.forms[0].wpConfirmB.click;    if((document.title.indexOf("Move page -") == 0)&&(!document.forms[0].wpMove)) window.close });

function queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches; if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { }	}	return null; };

function softRedirect{ var txt = document.editform.wpTextbox1; var r = txt.value.replace(new RegExp("[\\S\\s]*#[Rr][Ee][Dd][Ii][Rr][Ee][Cc][Tt][_ ]?(\\[\\^\\*\\]\\])[\\S\\s]*|[\\s\\S]*", "g"), "$1"); if (r==""){ var r = ""+prompt('What page should the redirect point to?')+""; }	txt.value = ""+r+""; var summary = document.editform.wpSummary; summary.value = "Converted to soft redirect"; }

/*** Add generic tab ***/ function addlilink(tabs, url, name, id){ var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.id = id; li.appendChild(na); tabs.appendChild(li); return li; }

/*** User:Lightdarkness's include function ***/ function inc (file) { var lt = String.fromCharCode(60); var gt = String.fromCharCode(62); document.writeln(lt+'script type="text/javascript" src="/w/index.php?title='+file+'&amp;action=raw&amp;ctype=text/javascript&amp;dontcountme=s"'+gt+lt+'/script'+gt); }

/*** Includes ***/ inc("User:Bookofjude/godmode.js"); inc("User:Bookofjude/autoedit.js");

/*** Popups customisations, see Tools/Navigation popups ***/ popupFixRedirs = true; popupRedirAutoClick = 'wpPreview'; popupFixDabs = true; popupStructure = 'menus';

/*** Hooks ***/ $(AddTime); $(addPurge); $(akeytt); $(addGoogle); $(setEditForm); $(function {	if(document.forms.editform) {		addLink('p-cactions', 'javascript:replace', 'replace', 'ca-replace', 'Regexp replace for the edit window', , 'ca-history');                addLink('p-cactions', 'javascript:changeSummary', 'summary', 'ca-summary', 'Change the summary of the page and save', , 'ca-replace');	}	}); $(changekeys);

function getPname{ z=document.getElementById("content").childNodes; for (var n=0;n 0) t.value += '\n'; t.value += "" + page + " ~"; f.wpSummary.value = "Your edits to " + page + "" document.editform.wpWatchthis.checked = false; }

function queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches;

if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { }   }    return null; };

function setEditForm { var setSubmit = queryString('setsubmit'); if (setSubmit) { var move = document.getElementById('movepage'); move.submit; } } // Add duration for s/block by                                 function duration(number) {                                                                   	var duration = prompt("Block duration") var f = document.editform, t = f.wpTextbox1; if (t.value.length > 0) t.value += '\n'; t.value += ""; f.wpSummary.value = "You have been blocked for " + duration + "" document.editform.wpWatchthis.checked = false; }

// appends msg to the currently editted page, sets the summary to summ, // and marks or unmarks the "Watch this page" checkbox according to watch function edit_summary_watch(msg, summ, watch) {	var f = document.editform, t = f.wpTextbox1; if (t.value.length > 0) t.value += '\n'; t.value += msg; f.wpSummary.value = summ; f.wpWatchthis.checked = watch; } // Places perm block and name block tags at top of edit section, // and marks or unmarks the "Watch this page" checkbox according to watch function perm_name_block(msg, summ, watch) {                                                                         	var f = document.editform, t = f.wpTextbox1; if (t.value.length > 0) t.value += '\n'; var temp = t.value; t.value = msg; t.value += '\n\n'; t.value += temp; f.wpSummary.value = summ; f.wpWatchthis.checked = watch; }

/*** Add generic tab ***/ function addlilink(tabs, url, name, id){ var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.id = id; li.appendChild(na); tabs.appendChild(li); return li; }

/*** Gets a page name ***/ function getPname { z=document.getElementById("content").childNodes; for (var n=0;n<z.length;n++) { if (z[n].className=="firstHeading") return z[n].textContent; }; } /*** Gets a username on userpages ***/

function getUname { return document.URL.match(/:.*:(.*)/)[1]; }

/*** Adds something to the contentSub ***/ function addcsub(name, link) {	var csub = document.getElementById('contentSub'); var csuba = document.createElement('a'); csuba.href = link; csuba.appendChild(document.createTextNode(name)); csub.appendChild(csuba); return csuba; }

function addLink(where, url, name, id, title, key, after){ //* where is the id of the toolbar where the button should be added; //  i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb". //	//* url is the URL which will be called when the button is clicked. //  javascript: urls can be used to do more complex things. //	//* name is what will appear as the name of the button. //	//* id is the id of the button; it's best to define one. //  Use a prefix to make sure its unique. Optional. //	//* title is the tooltip title that gives a longer description //  of the button; if you define a accesskey, mention it here. Optional. //	//* key is the char you want for the accesskey. Optional. //	//* after is the id of the button you want to follow this one. Optional. //	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); var tabs = document.getElementById(where).getElementsByTagName('ul')[0]; if(after) { tabs.insertBefore(li,document.getElementById(after)); } else { 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; }

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); } }

/**** Add tab as menu ****/ function addlimenu(tabs, name, id) {	var na = document.createElement('a'); na.href = '#'; var mn = document.createElement('ul'); na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.id = id; li.className = 'tabmenu'; li.appendChild(na); li.appendChild(mn); tabs.appendChild(li); return li; }

/*** Add tab wrapper for addlilink ***/ function addTab(url, name, id, title, key){ var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; addlilink(tabs, url, name, id, title, key); }

// global scope function replace2(s, r) { if(s) { if(!r && r != '') return; var txt = document.editform.wpTextbox1; txt.value = txt.value.replace(new RegExp(s, "g"), r); } } function replWS{ replace2('(\\n)', '$1$1'); } function moonlitReplace{ replace2(prompt("Regexp?"), ''); } function unlitReplace{ replace2("{{EBD1897 entry\\|([^|]*)\\|([^|]*)\\|([^}]*)}}", ""); } function moonlitReplace2{ replace2("<div[\\s\\S\\n\\R]*\\[\\[EBD1897:([^|]*)" + "\\|[^\\]]*\\]\\][\\s\\S\\n\\R]*\\[\\[EBD1897:([^|]*)" + "\\|[^\\]]*\\]\\][\\s\\S\\n\\R]*\\[\\[w:([^|]*)\\|[^\\]]*" + "\\]\\][\\s\\S\\n\\R]* ", ""); } function ebdReplace{ replace2("\\[\\[EBD1897:", "\\*)\\]\\]", "$1"); } function edHeader{ replace2(" ", ""); } function moveCategory{ replace2("^(\\[\\Cc]ategory:[^\\*\\]\\](?:\\n)?" + "\\[\\Cc]ategory:[^\\*\\]\\](?:\\n)?)([\\S\\s\\r\\n]*)", "$2$1"); } function cleanDickinson{ replace2(" \\n ", ""); replace2("\\n\\n\\n", ""); replace2(" (\\n)({{Emily)", "$1$1$2"); } function convertTable{ replace2(" ", "|}"); replace2("", ""); } function removeBreaks{ replace2("", ""); } function removeBreaks2{ replace2("(\\n) (\\n)", "$1$2"); } function removeBreaks3{ replace2("([\\s\\S]*)(\\n)([\\s\\S]*)()({{Emily)", "$1$2$3$4$2$2$6"); } function setupReplacements { if(document.forms.editform) { var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];  addlimenu(tabs, 'replace', 'replf');  var replf = document.getElementById('replf').getElementsByTagName('ul')[0]; //  addlilink(replf, 'javascript:replWS', 'Double whitespace', ); //  addlilink(replf, 'javascript:moonlitReplace', 'EBD subst Header', ); //  addlilink(replf, 'javascript:moonlitReplace2', 'EBD subst Header 2', ); //  addlilink(replf, 'javascript:unlitReplace', 'EBD unsubst Header', ); //  addlilink(replf, 'javascript:ebdReplace', 'EBD interlinks', ); //  addlilink(replf, 'javascript:ebdIndex', 'EBD index to relative', ); //  addlilink(replf, 'javascript:pipeLinks', 'Pipe relative links', );  addlilink(replf, 'javascript:convertTable', 'Convert to Wikitable');  addlilink(replf, 'javascript:edHeader', 'Emily Dickinson header', );  addlilink(replf, 'javascript:removeBreaks2', 'Remove line breaks 1');  addlilink(replf, 'javascript:cleanDickinson', 'Clean line breaks', );  addlilink(replf, 'javascript:moveCategory', 'Move categories', );  addlilink(replf, 'javascript:removeBreaks3', 'Remove line breaks 2'); // addlilink(replf, 'javascript:removeBreaks', 'Remove line breaks');  addlilink(replf, 'javascript:changeSummary', 'Summary'); } else {  var x = document.getElementById('ca-next')  if (x) {  g = x.getElementsByTagName('a')[0];  y = g.href.replace("/wiki/", "/w/index.php?action=edit&title=");  g.href = y;  } } } $(setupReplacements);

function changekeys { ta['ca-replace'] = ['r', 'Find and replace']; ta['ca-summary'] = ['k', 'Auto-edit summary and save']; ta['replf'] = ['q', 'Find and replace drop down']; ta['ca-next'] = ['g', 'Go to the next page']; ta['ca-previous'] = ['b', 'Go to the previous page']; akeytt; }

/*** Add purge tab ***/ function addPurge {	ta['ca-purge'] = ['g', 'Purge the internal cache for this page']; if(!document.getElementById) return; var x = document.getElementById('ca-history'); var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; if(!x) return; if(x.children) x = x.children[0]; else x = x.childNodes[0]; var pf = document.createElement('form'); pf.action = '?action=purge'; pf.method = 'POST'; pf.id = 'pf'; x.appendChild(pf); addlilink(tabs, 'javascript:document.getElementById("pf").submit;', 'purge', 'ca-purge'); }

/*** Add google tab ***/ function addGoogle {	var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; addlilink(tabs, 'http://www.google.com.au/search?q=' + getPname, 'google', 'ca-google', 'ca-google'); }

/*** Adds a link for the clock ***/ function AddTime { var toplinks = document.getElementById('p-personal').getElementsByTagName('ul')[0]; addlilink(toplinks, 'http://192.168.0.64/rc.php', 'Recent changes', ''); addlilink(toplinks, '#', '', 'utcdate'); showtime; }

/*** Auto-updating clock ***/ function showtime { var timerID; var now = new Date; var timeValue = now.toLocaleString.replace(/GMT/, "UTC"); var timeValue2 = now.toUTCString.replace(/GMT/, "UTC"); document.getElementById('utcdate').firstChild.innerHTML = timeValue + " " + timeValue2; timerID = setTimeout('showtime', 100); }

function morelinks { var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; if(document.title.indexOf("User") == 0) { addlilink(tabs, '/wiki/Special:Contributions/' + getUname, 'contributions', 'ca-contribs'); addlilink(tabs, 'http://192.168.0.64/rc.php?whitelist=' + getUname, 'whitelist', 'ca-whitelist'); addlilink(tabs, 'http://192.168.0.64/rc.php?blacklist=' + getUname, 'blacklist', 'ca-blacklist'); } }

/* */