User:Dp462090/wowwiki.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 **/

/*** 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:Lupin/popups.js"); inc("User:Jnothman/afd_helper/script.js"); inc("User:Bookofjude/statuschanger.js"); inc("User:Interiot/Tool2/code.js");

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

/*** Hooks ***/ addOnloadHook(AddTime); addOnloadHook(addPurge); addOnloadHook(changeRecent); addOnloadHook(addEditSection0); addOnloadHook(changeLinks); addOnloadHook(morelinks); addOnloadHook(addToolBoxLinks); addOnloadHook(addWatch); addOnloadHook(akeytt); addOnloadHook(addNavBarLinks); addOnloadHook(addGoogle); addOnloadHook(function {	if(document.forms.editform) {		addLink('p-cactions', 'javascript:replace', 'replace', 'ca-replace', 'Regexp replace for the edit window', '', 'ca-history');	}	});

/*** GENERIC FUNCTIONS ***/

/**** Tabs and functions ****/ // Add test-n templates to user talk pages function testn(number) {	var page = prompt("Vandalism to which article?") var f = document.editform, t = f.wpTextbox1; if (t.value.length > 0) t.value += '\n'; t.value += "" + page + " ~"; f.wpSummary.value = "Your edits to " + page + "" document.editform.wpWatchthis.checked = false; } // 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); }

/*** Edit section 0 ***/ function addEditSection0 {	ta['ca-edit-0'] = ['', 'Edit the zeroth section of this page']; 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&section=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&section=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 + '&section=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 + '&section=0'; z.appendChild(document.createTextNode('0')); y.appendChild(z); document.getElementById('p-cactions').childNodes[3].insertBefore(y,x.nextSibling); } }

/*** 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 article watchlist tab ***/ function addWatch {	if (!location.href.indexOf("Special:") == -1) { ta['ca-watchlist'] = ['u', 'Add this article to Wikibot watchlist']; if(!document.getElementById) return; 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')); addlilink(tabs, 'http://192.168.0.64/rc.php?watchlist=' + editlk, 'watchlist', 'ca-watchlist', 'ca-watchlist'); } }

/*** 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'); } /*** Change recent changes link ***/ function changeRecent {	var portlet = document.getElementById('n-recentchanges'); portlet.innerHTML = "Recent changes"; }

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

/*** AFD FUNCTIONS ***/

/*** Add afd header, footer and comment ***/ function closeafd(bold, notbold) {	var txt = document.editform.wpTextbox1; txt.value = " " + bold + "" + notbold + ". – ~\n" + txt.value + "\n\n"; txt = document.editform.wpSummary; txt.value = "close discussion: " + bold + notbold; document.editform.wpWatchthis.checked = false; } /*** Talk page AFD result ***/ function afdresult {	var res = prompt("Result?"); if(!res) return; var afddate = prompt("Nomination date?"); document.editform.wpSummary.value = 'AFD result - ' + res.replace(/'/g, ''); var txt = document.editform.wpTextbox1; if(txt.value.length > 0) txt.value += '\n'; txt.value += ''; txt.focus; } /*** Make old AfD's appear or disappear ***/ function hideafd {	var divs = document.getElementsByTagName("div"); for(var x = 0; x < divs.length; ++x) if(divs[x].className.indexOf("vfd") != -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].style.display = ""; document.getElementById('footer').style.display = ''; }

/*** Not sure how this works ***/ function afddelete{ //   var form = document.forms.deleteconfirm; //   form.wpReason.value = 'Articles for deletion/' + unescape(window.location.href.replace(/^.*\?title=([^&]+)&action=delete.*$/, '$1').replace(/_/g, ' ')) + ''; //   form.wpConfirm.checked = true; }

/*** Make the top links look better ***/ 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'; }

/**** Automatically-updating word count on edit pages ****/

/*** Count words in a field ***/ function countWords(field) { return field && field.value ? field.value.split(/\s+/).length : 0; }

/*** Creates div ***/ function doWordCount { if (document.title.slice(0,7) == "Editing") { var x = document.getElementById('editpage-copywarn'); var y = document.getElementById('editform'); if (x && y && y.wpTextbox1) { var z = document.createElement('div'); z.id = 'word-count'; x.appendChild(z); refreshCount; } else { alert('Missing element needed for word count'); }	} }

/*** Auto-updated ***/ function refreshCount { var wc = ' Word count: ' + countWords(document.getElementById('editform').wpTextbox1) + ' '; document.getElementById('word-count').innerHTML = wc; setTimeout(refreshCount, 10000); }

function morelinks { var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; if(document.title.indexOf("Editing User talk:") == 0) { addlimenu(tabs, 'Talk page messages', 'talkm'); var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0]; // Welcome menu addlimenu(talkm, 'Welcome', 'welcomess'); var welcomess = document.getElementById('welcomess').getElementsByTagName('ul')[0]; addlilink(welcomess,'javascript:edit_summary_watch(" ~", "Welcome to Wikipedia!", true, 1)','Welcome', ''); addlilink(welcomess,'javascript:edit_summary_watch(" ~", "Welcome to Wikipedia!", true, 1)','Anon', ''); // Test menu addlimenu(talkm, 'Test[x]', 'testx'); var testx = document.getElementById('testx').getElementsByTagName('ul')[0]; addlilink(testx,'javascript:testn("nn-test")','Non-notable test', ''); addlilink(testx,'javascript:testn("test0")', 'Test0', ''); addlilink(testx,'javascript:testn("test1")', 'Test1', ''); addlilink(testx,'javascript:testn("test2")','Test2', ''); addlilink(testx,'javascript:testn("test2a")','Test2a', ''); addlilink(testx,'javascript:testn("test3")','Test3', ''); addlilink(testx,'javascript:testn("test4")','Test4', ''); addlilink(testx,'javascript:testn("test4-im")','Only warning', ''); addlilink(testx,'javascript:testn("User:Bookofjude/tpv1")','Talk page vandalism 1', ''); addlilink(testx,'javascript:edit_summary_watc(" ~", "Blanking your talk page", false, 1)', 'Warning blankings 1', ''); // Blatant vandalism addlimenu(talkm, 'Blatant vandalism', 'bv') var bv = document.getElementById('bv').getElementsByTagName('ul')[0]; addlilink(bv,'javascript:testn("vw")','Blatant vandalism 1', ''); addlilink(bv,'javascript:testn("bv")','Blatant vandalism 2', ''); addlilink(bv,'javascript:edit_summary_watch(" ~", "Blanking pages", false, 1)','blanking', ''); // Spam addlimenu(talkm, 'Spam', 'spam'); var spam = document.getElementById('spam').getElementsByTagName('ul')[0]; addlilink(spam,'javascript:edit_summary_watch(" ~", "Adding links to Wikipedia", false, 1)','Spam1', ''); addlilink(spam,'javascript:edit_summary_watch(" ~", "Spamming", false, 1)','Spam2', ''); addlilink(spam,'javascript:edit_summary_watch(" ~", "Last warning for spamming", false, 1)','Spam3', ''); addlilink(spam,'javascript:edit_summary_watch(" ~", "You have been blocked for spamming", false, 1)','Spam4', ''); // Talk page messages addlimenu(talkm, 'Talk messages', 'tkm'); var tkm = document.getElementById('tkm').getElementsByTagName('ul')[0]; addlilink(tkm,'javascript:edit_summary_watch(" ~", "Edit summaries", false, 1)','Edit summary 1', ''); addlilink(tkm,'javascript:edit_summary_watch(" ~", "Messages in articles", false, 1)','Messages 1', ''); addlilink(tkm,'javascript:edit_summary_watch(" ~", "Messages in articles", false, 1)','Messages 2', ''); addlilink(tkm,'javascript:edit_summary_watch(" ~", "Messages in articles", false, 1)','Messages 3', ''); addlilink(tkm,'javascript:edit_summary_watch(" ~", "About the page you created", false, 1)','Vanity', ''); addlilink(tkm,'javascript:edit_summary_watch(" ~", "About your edits", false, 1)','nothanks', ''); addlilink(tkm,'javascript:edit_summary_watch(" ~", "", false, 1)','nothanks-sd', ''); addlilink(tkm,'javascript:rvfd(1)', 'rvfd', ''); // Block messages // addlilink(talkm,'javascript:duration(1)', 'Temp Block', ''); // addlilink(talkm,'javascript:perm_name_block("", "You have been indefinitely blocked", true, 1)','Perm Block', ''); // addlilink(talkm,'javascript:perm_name_block(" ~", "", true, 1)','Name Block', ''); } else if(document.title.indexOf("Wikipedia:Articles for deletion") == 0) { addlilink(tabs, 'javascript:hideafd', 'hide closed', 'ca-hide'); ta['ca-hide'] = ['', 'Hide closed AFDs']; addlilink(tabs, 'javascript:showafd', 'show closed', 'ca-show'); ta['ca-show'] = ['', 'Show closed AFDs']; } else 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'); } } /*** Add links to the toolbox ***/

function addToolBoxLinks {	if(document.title.indexOf("User:") == 0) { var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; addlilink(tb, '/wiki/Special:Ipblocklist', 'IPBlocklist', ''); addlilink(tb, '/wiki/Wikipedia:Template messages/User_talk_namespace', 'Talk templates', ''); addlilink(tb, '/wiki/Wikipedia:Template_messages', 'Templates', ''); addlilink(tb, '/wiki/WP:CSD', 'SD criteria', ''); username_a = document.URL.match(/:.*:(.*)/); username=username_a[1]; addlilink(tb, 'http://www.math.ucla.edu/~aoleg/wp/rfa/edit_summary.cgi?user=' + getUname + '&lang=en', 'User\'s edit summary calculations'); addlilink(tb, 'http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?dbname=enwiki_p&user=' + getUname, 'User\'s edit count', ''); var username=document.getElementById("pt-userpage").textContent; addlilink(tb, 'http://www.math.ucla.edu/~aoleg/wp/rfa/edit_summary.cgi?user=' + username + '&lang=en', 'My edit summary calculations'); addlilink(tb, 'http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?dbname=enwiki_p&user=' + username, 'My edit count', ''); addlilink(tb, '/wiki/Special:Log', 'Log', ''); addlilink(tb, '/wiki/Category:Requests for unblock', 'Unblock requests', ''); } } /*** Add navigation bar links ***/ function addNavBarLinks { var navbar = document.getElementById('p-navigation').getElementsByTagName('ul')[0]; var afdtime = new Date; var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; addlilink(navbar, '/w/index.php?title=Special:Recentchanges&hidemyself=1&hideminor=1&hideliu=1', 'Recent changes 2', ''); addlilink(navbar, '/wiki/Wikipedia:Articles_for_deletion/Log/' + afdtime.getUTCFullYear		+ '_' + months[afdtime.getUTCMonth] + '_' + afdtime.getUTCDate, 'Today\'s AfD', ''); afdtime.setUTCDate(afdtime.getUTCDate - 5); addlilink(navbar, '/wiki/Wikipedia:Articles_for_deletion/Log/' + afdtime.getUTCFullYear		+ '_' + months[afdtime.getUTCMonth] + '_' + afdtime.getUTCDate, '5-day-old AfD', ''); var username=document.getElementById("pt-userpage").textContent; addlilink(navbar, '/w/index.php?title=User:' + username + '/monobook.js&action=edit', 'My monobook.js', ''); addlilink(navbar, '/w/index.php?title=User:' + username + '/monobook.css&action=edit', 'My monobook.css', ''); addlilink(navbar, '/wiki/User:Bookofjude/Sandbox', 'My sandbox', ''); }

// This is based on the original code on Wikipedia:Tools/Editing tools // // The original code was on the project page and needed to be cut and paste to the user's // monobook.js page. However, this caused problems with the quote marks. So I have moved // it to its own page. // // I do not know a lot about Javascript so please do not ask for a complicated change // // Changed 24/02/2006 - Window.Onload replaced with addOnloadHook

function InsertButtonsToToolBar { tooly = document.getElementById('toolbar');

if (tooly != null) { StrikeTextButton = "";

LeftTextButton = "\\n','\\n ','Left-aligned text');\">";

CenterTextButton = "',' ','Centered text');\">";

TableButton = "";

EenterButton = "</a>";

UpperTextButton = "<img src=\"http://upload.wikimedia.org/wikipedia/en/8/80/Button_upper_letter.png\" alt=\"Superscript\" title=\"Superscript text\"></a>";

LowerTextlButton = "<img src=\"http://upload.wikimedia.org/wikipedia/en/7/70/Button_lower_letter.png\" alt=\"Subscript\" title=\"Subscript text\"></a>";

SmallTextButton = "<img src=\"http://upload.wikimedia.org/wikipedia/en/5/58/Button_small.png\" alt=\"Small\" title=\"Small text\"></a>";

CommentButton = "<img src=\"http://upload.wikimedia.org/wikipedia/en/3/34/Button_hide_comment.png\" alt=\"Comment\" title=\"Insert hidden comment\"></a>";

GalleryButton = "<img src=\"http://upload.wikimedia.org/wikipedia/en/1/12/Button_gallery.png\" alt=\"Gallery\" title=\"Insert a picture gallery\"></a>";

SecondaryHeadlineButton = "<img src=\"http://upload.wikimedia.org/wikipedia/en/e/e9/Button_headline2.png\" alt=\"2nd header\" title=\"Insert secondary headline\"></a>";

ShiftingButton = "<img src=\"http://upload.wikimedia.org/wikipedia/en/8/8e/Button_shifting.png\" alt=\"Tab\" title=\"Insert tab(s)\"></a>";

BlockQuoteButton = "\\n','\\n ','Block quote');\"><img src=\"http://upload.wikimedia.org/wikipedia/en/f/fd/Button_blockquote.png\" alt=\"Block quote\" title=\"Insert block of quoted text\"></a>";

FontColorButton = "',' ','Span of text');\"><img src=\"http://upload.wikimedia.org/wikipedia/en/1/1e/Button_font_color.png\" alt=\"Color\" title=\"Insert colored text\"></a>";

CodeButton = "<img src=\"http://upload.wikimedia.org/wikipedia/en/2/23/Button_code.png\" alt=\"Code\" title=\"Insert code\"></a>";

SubLinkButton = "<img src=\"http://upload.wikimedia.org/wikipedia/en/9/93/Button_sub_link.png\" alt=\"sub-page link\" title=\"Insert link to sub-page\"></a>";

DefinitionListCodeButton = "<img src=\"http://upload.wikimedia.org/wikipedia/en/d/d3/Button_definition_list.png\" alt=\"Definition\" title=\"Insert definition list\"></a>";

extraHTML = StrikeTextButton + LeftTextButton + CenterTextButton + TableButton + EenterButton + UpperTextButton + LowerTextlButton + SmallTextButton + CommentButton + GalleryButton + SecondaryHeadlineButton + ShiftingButton + BlockQuoteButton + FontColorButton + CodeButton + SubLinkButton + DefinitionListCodeButton;

node2 = document.createElement("span"); tooly.parentNode.insertBefore(node2, tooly.nextSibling); node2.innerHTML=extraHTML;

} } addOnloadHook( InsertButtonsToToolBar );

function externISBN { for (var i = 0; i < document.links.length; i++) {               var ln = document.links[i].href.match(/isbn=(.*)/); if (ln) { document.links[i].href='http://www.amazon.com/exec/obidos/ASIN/'+RegExp.$1; }   }

}

addOnloadHook(externISBN); /* */