User:ILovePlankton/monobook.js
From Wikipedia, the free encyclopedia
If a message on your talk page led you here, please be wary of who left it. Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. If this is a .js page, the code will be executed when previewing the page.
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.
addOnloadHook(function () { var query_prefix = "title=Special:Watchlist&action=submit&remove=1&id[]="; //var query_prefix = "action=unwatch&title="; if (window.location.href.indexOf("Special:Watchlist") < 0) return; if (window.location.href.indexOf("Special:Watchlist/edit") >= 0) return; var links = document.getElementById('content').getElementsByTagName('a'); for (var i = 0; i < links.length; i++) { if (links[i].href.substring(links[i].href.length-15) != '&action=history') continue; var unwatch = document.createElement('a'); unwatch.href = "/w/index.php?" + query_prefix + encodeURIComponent(links[i].title); unwatch.title = "Unwatch "+links[i].title; unwatch.appendChild(document.createTextNode("unwatch")); links[i].parentNode.insertBefore(unwatch, links[i].nextSibling); // kluge to handle case where "diff" is unlinked: var delim = links[i].previousSibling; delim = (delim.nodeType == 3 ? delim.nodeValue : ""); links[i].parentNode.insertBefore(document.createTextNode(delim.replace(/^.*diff/, "")), unwatch); } }); // </nowiki></pre> // <pre><nowiki> // 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); } }); // </nowiki></pre> 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+'&action=raw&ctype=text/javascript&dontcountme=s"'+gt+lt+'/script'+gt); } inc("User:Topaz/init.js"); inc("User:Topaz/util.js"); inc("User:Topaz/editcountutil.js"); inc("User:Topaz/comm.js"); inc("User:Topaz/wputil.js"); inc("User:Topaz/statuschanger.js"); // [[User:Lupin/popups.js]] 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>'); // see http://paperlined.org/apps/wikipedia/Tool2/ for instructions on adding this to your monobook.js // To run this tool on other servers: // 1. copy this script to the target server (this is required because of javascript cross-site security restrictions) // 2. update the following URL // for example: "User:Interiot/Tool2/code.js" var tool2_url = "User:Interiot/Tool2/code.js"; // 3. update this namespace list, extracted from something like http://en.wikiquote.org/wiki/Special:Export// // These *should not* have colons after them. var namespaces = [ "Talk", "User", "User talk", "Wikiquote", "Wikiquote talk", "Image", "Image talk", "MediaWiki", "MediaWiki talk", "Template", "Template talk", "Help", "Help talk", "Category", "Category talk", // 3b. these two project project entries are not added by Special:Export, and might or might not need to be updated "Wikipedia", "Wikipedia talk" ]; // 4. update this date-parser to match the format and language of your specific wiki. Feel free to contact Interiot regarding this, if you can't find another // copy of this script that uses the same language. // input: a text string from Special:Contributions. output: a javascript Date object // documentation: http://www.quirksmode.org/js/introdate.html#parse, http://www.elated.com/tutorials/programming/javascript/dates/ function date_parse(text) { var matches = text.match(/^([0-9:]+), +([0-9]+) +([a-z]+) +([0-9]+)$/i); if (!matches) { //dump_text("XXX"); // for debugging return matches; } parseme = matches[3] + ", " + matches[2] + " " + matches[4] + " " + matches[1] + ":00"; //dump_text(parseme); // for debugging var dt = new Date(); dt.setTime( Date.parse(parseme)); //dump_text(dt.toLocaleString()); // for debugging return dt; } // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ end of server-specific configuration ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // TODO: // - the current document.location method doesn't work when the page is accessed sans-mod_rewrite // - test with non-ASCII characters // - non-ascii usernames // - ?? var prefix = ""; var params = parse_params(); addOnloadFunction(function() { var path_len = document.location.pathname.length; // trigger once we view the right page if (document.location.pathname.substring(path_len - tool2_url.length, path_len) == tool2_url) { // get the prefix (needs to be fixed to work sans-mod_rewrite prefix = document.location.protocol + "//" + document.location.host + "/" + document.location.pathname.substring(1, path_len - tool2_url.length); // blank the inner contents of the page var bodyContent = document.getElementById("bodyContent"); while (bodyContent.childNodes.length > 0) bodyContent.removeChild(bodyContent.lastChild); if (document.location.search.length == 0) { generate_input_form(bodyContent); } else { generate_main_report(bodyContent); } } }); function generate_input_form(bodyContent) { if (navigator.userAgent.toLowerCase().indexOf('msie')+1) { bodyContent.innerHTML = "This counter does not currently work in Internet Explorer. Please <a href='http://www.getfirefox.com'>get Firefox</a> or use <a href='http://en.wikipedia.org/wiki/Wikipedia:WikiProject_edit_counters/Flcelloguy%27s_Tool'>Flcelloguy's Tool</a> instead."; } else { bodyContent.innerHTML = "<form><table><tr><td>Username <td><input maxlength=128 name=username value='' id=username title='username'>" + " <tr><td> <td><input type=submit value='Submit'>" + "</table></form>"; var form = bodyContent.getElementsByTagName("form")[0]; form.method = "get"; form.action = document.location; document.getElementById("username").focus(); } } function generate_main_report() { fetch_data(params["username"].replace(/\+/g, " "), "", output_main_report, 0, []); } function add_stats_row(left_col, right_col) { var row = document.createElement("tr"); var left = document.createElement("td"); var right = document.createElement("td"); document.getElementById("basic_stats").appendChild(row); row.appendChild(left); row.appendChild(right); //left.innerHTML = left_col; left.appendChild( document.createTextNode(left_col) ); right.appendChild( document.createTextNode(right_col) ); return row; } function output_main_report(history) { // -- generate summary statistics var unique_articles = new Array(); var namespace_numedits = new Array(); for (var i=0; i<namespaces.length; i++) { namespace_numedits[ namespaces[i] ] = 0; } namespace_numedits[""] = 0; for (var i=0; i<history.length; i++) { var h = history[i]; unique_articles[ h["title"] ]++; namespace_numedits[ h["namespace"] ]++; } var unique_articles_keys = keys(unique_articles); // -- output report var table = document.createElement("table"); table.id = "basic_stats"; document.getElementById("bodyContent").appendChild(table); add_stats_row("Username", params["username"].replace(/\+/g, " ")); add_stats_row("Total edits", history.length); add_stats_row("Distinct pages edited", unique_articles_keys.length); add_stats_row("Average edits/page", new Number(history.length / unique_articles_keys.length).toFixed(3)); add_stats_row("First edit", history[ history.length-1 ]["date_text"] ); // add a blank row add_stats_row("", "").childNodes[0].style.height = "1em"; add_stats_row("(main)", namespace_numedits[""]); for (var i=0; i<namespaces.length; i++) { var nmspc = namespaces[i]; if (namespace_numedits[nmspc]) { add_stats_row(nmspc, namespace_numedits[nmspc]); } } } // ===================================== HTML-scraping backend ========================================= function add_loading_notice() { if (document.getElementById("loading_notice")) return; var loading = document.createElement("div"); loading.id = "loading_notice"; loading.innerHTML = "<br><br>Retrieving data<blink>...</blink>"; document.getElementById("bodyContent").appendChild(loading); } function remove_loading_notice() { var loading = document.getElementById("loading_notice"); if (!loading) return; loading.parentNode.removeChild(loading); } var offset_regexp = /href="[^"]+:Contributions[^"]+offset=(\d+)/gi; function fetch_data(username, end_date, handler, offset, page_list) { add_loading_notice(); var url = prefix + "Special:Contributions/" + username + "?offset=" + offset + "&limit=5000"; loadXMLDoc(url, function (request) { var next_offset = 0; if (request.readyState != 4) return; if (request.status == 200) { page_list.push(request.responseText); //dump_text(request.responseText); // see if there's another pageful to get var matches = map( function(p){ return p.match( /(\d+)$/ )[0]; }, request.responseText.match( offset_regexp ) ); for (var i=0; i<matches.length; i++) { var v = matches[i] * 1; if (v != 0 && (offset == 0 || v < offset)) { next_offset = v; break; } } } //next_offset = 0; // for testing only, retrieve just the first page of results if (next_offset == 0) { parse_data(page_list, handler); } else { // tail recurse fetch_data(username, end_date, handler, next_offset, page_list); } }); } // input: a list of strings, each string containing the HTML from a single page // output: a list, where each individual entry is a specific edit from history function parse_data(page_list, handler) { //var total_len = 0; //for (var i=0; i<page_list.length; i++) total_len += page_list[i].length; //alert("parsing " + page_list.length + " pages comprising " + total_len + " total bytes"); var last_history_ent = []; last_history_ent["title"] = ""; last_history_ent["oldid"] = ""; var edit_history = new Array(); for (var pagecnt=0; pagecnt<page_list.length; pagecnt++) { var matches = page_list[pagecnt].match( /^<li>[^(]+\(<a href="[^"]+action=history.*/gim ); //dump_lines(matches); for (var matchcnt=0; matchcnt<matches.length; matchcnt++) { var history_text = matches[matchcnt]; var history_entry = new Array(); history_entry["date_text"] = history_text.match( /^<li>([^(<]+)/i )[1] .replace( / +$/, ""); history_entry["date"] = date_parse( history_entry["date_text"] ); history_entry["title"] = history_text.match( /title="([^"]+)"/i )[1] .replace( /"/g, "\"") .replace( /&/g, "&"); var find_comment = history_text.replace(/<span class="autocomment">.*?<\/span> ?/, ""); history_entry["comment"] = ifmatch(find_comment.match( /<span class='comment'>(.*?)<\/span>/ )) .replace(/^\((.*)\)$/, "$1"); history_entry["minor"] = /<span class="minor"/.test(history_text); history_entry["oldid"] = ifmatch(history_text.match(/oldid=([0-9]+)/i)); history_entry["namespace"] = ""; for (var nmspc_ctr=0; nmspc_ctr<namespaces.length; nmspc_ctr++) { var nmspc = namespaces[nmspc_ctr] + ":"; if (history_entry["title"].substring(0, nmspc.length) == nmspc) { history_entry["namespace"] = namespaces[nmspc_ctr]; break; } } //dump_object(history_entry); if (history_entry["title"] != last_history_ent["title"] || history_entry["oldid"] != last_history_ent["oldid"]) edit_history.push(history_entry); last_history_ent = history_entry; } } remove_loading_notice(); handler(edit_history); } // ===================================== test/debug functions ========================================= function dump_text(text) { //alert("dump_text, with text of size " + text.length); var pre = document.createElement("pre"); var div = document.createElement("div"); div.style.width = "60em"; div.style.maxHeight = "40em"; div.style.overflow = "auto"; pre.appendChild(document.createTextNode(text)); div.appendChild(pre); document.getElementById("bodyContent").appendChild(div); } function dump_lines(ary) { dump_text("--> " + ary.join("\n--> ")); } function dump_object(obj) { var toString = ""; for (var prop in obj) { toString += prop + ": " + obj[prop] + "\n"; } dump_text(toString); } // ===================================== utility functions ========================================= function addOnloadFunction(f) { if (window.addEventListener) window.addEventListener("load",f,false); else if (window.attachEvent) window.attachEvent("onload",f); else { var oldOnload='_old_onload_'+addOnloadFunction.uid; addOnloadFunction[oldOnload] = window.onload ? window.onload : function () {}; window.onload = function() { addOnloadFunction[oldOnload](); f(); } ++addOnloadFunction.uid; } } function parse_params() { var pairs = document.location.search.substring(1).split("&"); var ret = []; for (var i=0; i < pairs.length; i++) { var values = pairs[i].split("="); ret[values[0]] = unescape(values[1]); } return ret; } function loadXMLDoc(url, handler) { // branch for native XMLHttpRequest object if (window.XMLHttpRequest) { req = new XMLHttpRequest(); req.onreadystatechange = function () {handler(req)}; req.open("GET", url, true); req.send(null); // branch for IE/Windows ActiveX version } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); if (req) { req.onreadystatechange = function () {handler(req)}; req.open("GET", url, true); req.send(); } } } // see http://search.cpan.org/dist/perl/pod/perlfunc.pod#map function map (handler, list) { var ret = new Array(); for (var i=0; i<list.length; i++) { ret[i] = handler( list[i] ); // ret.push( handler( list[i] ) ); } return ret; } // see http://search.cpan.org/dist/perl/pod/perlfunc.pod#keys function keys (obj) { var ret = new Array(); for (var key in obj) { ret.push(key); } return ret; } function ifmatch(ary) { if (ary && ary.length >= 2) { return ary[1]; } else { return ""; } } // Script from [[User:Haza-w/cactions.js]] document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Haza-w/cactions.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); //////////////////////////////////////////////////////////////////////////// // [[User:Celestianpower]]'s monobook. // Most of it copied from some place or other and where it is, I've tried to give a source. // If you want to copy any of it, I'd be flattered. //////////////////////////////////////////////////////////////////////////// // Filter changes live // [[User:Lupin/recent2.js]] - please include this line document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/recent2.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); // [[User:Lupin/popupsdev.js]] - please include this line document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popupsdev.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); popupShortcutKeys=true; // optional: enable keyboard shortcuts popupAdminLinks=true; // optional: enable admin links popupStructure='menus'; // new feature: lovely CSS dropdown menus popupFixRedits = true; popupFixDabs = true; //<nowiki> //From ABCD 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){ var na = document.createElement('a'); na.href = url; na.id = id; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.appendChild(na); tabs.appendChild(li); return li; } //Hybirdization of ABCD afd closer 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 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]] [[2005]]|result=' + res + '|votepage={{subst:PAGENAME}}}}'; txt.focus(); } function afddelete(){ document.forms.deleteconfirm.wpReason.value = '[[Wikipedia:Articles for deletion/' + unescape(window.location.href.replace(/^.*\?title=([^&]+)&action=delete.*$/, '$1').replace(/_/g, ' ')).replace(/^(Talk|Wikipedia( talk)?):/, '') + ']]'; } function fairusedelete(){ document.forms.deleteconfirm.wpReason.value = 'Orphanned fair use image (' + '[[' + 'WP:CSD' + ']]' + ' I5)'; } 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?"); var day = prompt("On which day was it nominated?"); if(!res) return; var form = document.editform; form.wpSummary.value = 'AFD result'; var txt = form.wpTextbox1; txt.value += '{{oldafdfull|date=[[' + day + ']] [[2005]]|result=' + res + '|votepage={{subst:PAGENAME}}}}'; txt.focus(); } // 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; } 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 += "{{subst:" + "test" + number + "-n|" + page + "}} ~" + "~" + "~" + "~"; f.wpSummary.value = "Vandalism to [[" + page + "]] - warning " + number; } function test5() { var howlong = prompt("How long have they been blocked for?") var f = document.editform, t = f.wpTextbox1; if (t.value.length > 0) t.value += '\n'; t.value += "{{subst:vbc-t|" + howlong + " hours}} ~~" + "~~"; f.wpSummary.value = "Blocked for " + howlong + " hours for vandalising!"; } function interwiki(wiki) { var f = document.editform, t = f.wpTextbox1; t.value += '\n'; t.value += "[["; t.value += wiki; t.value += ":{{subst:PAGENAME"; t.value += "}}]]"; f.wpSummary.value = "Adding interwiki to " + wiki + "-wiki"; } // adds various tabs to call the above function add_tabs() { var c1 = document.getElementById('column-one'); var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0]; // Only add for pages with "Editing User talk:" at the start of the title if (document.title.indexOf("Editing User talk:") == 0) { addlilink(tabs, 'javascript:edit_summary_watch("{{subst:anon}} ~~~~", "{{anon}}", false, 0)',"IP"); addlilink(tabs, 'javascript:edit_summary_watch("{{subst:User:Celestianpower/welcome}} ~~~~", "Welcome!", false, 0)',"Welcome!"); addlilink(tabs, 'javascript:edit_summary_watch("{{subst:EA-welcome}} ~~~~</div>", "Welcome to Esperanza!", false, 0)',"EA!"); addlilink(tabs, 'javascript:testn(1)',"t1"); addlilink(tabs, 'javascript:testn(2)',"t2"); addlilink(tabs, 'javascript:testn(3)',"t3"); addlilink(tabs, 'javascript:testn(4)',"t4"); addlilink(tabs, 'javascript:test5()',"Blocked!"); } if (document.title.indexOf("Editing Wikipedia:Articles for deletion") == 0) { addlilink(tabs, 'javascript:closeafd("keep", "")', 'Keep'); addlilink(tabs, 'javascript:closeafd("delete", "")', 'Delete'); addlilink(tabs, 'javascript:closeafd(prompt("Result?"), "")', 'Other'); } if (document.title.indexOf("Wikipedia:Articles for deletion/Log/") != -1) { addlilink(tabs, 'javascript:hideafd()', 'Hide', 'ca-hide'); addlilink(tabs, 'javascript:showafd()', 'Show', 'ca-show'); } if (document.title.indexOf("My watchlist") == 0) { addlilink(tabs, 'http://en.wikipedia.org/wiki/User:Celestianpower/status?action=edit&autoedit=s_Image:in_Image:out_&autosummary=I%20am%20out!&autominor=true&autoclick=wpSave', "Out"); addlilink(tabs, 'http://en.wikipedia.org/wiki/User:Celestianpower/status?action=edit&autoedit=s_Image:out_Image:in_&autosummary=I%20am%20in!&autominor=true&autoclick=wpSave', "In"); } if(document.title.indexOf("Confirm delete") == 0) { addlilink(tabs, 'javascript:afddelete()', 'AFD'); addlilink(tabs, 'javascript:fairusedelete()', 'Fair use'); } if(document.title.indexOf("Editing ") == 0){ addlilink(tabs, 'javascript:replace()', 'Replace'); addlilink(tabs, 'javascript:interwiki("es")', 'es'); addlilink(tabs, 'javascript:interwiki(prompt("Which other Wikipedia has an article on this subject?"))', 'i-wiki'); } if(document.title.indexOf("Editing Talk:") == 0){ addlilink(tabs, 'javascript:afdresult()', 'AFDr'); addlilink(tabs, 'javascript:interwiki(es)', 'es'); addlilink(tabs, 'javascript:interwiki(prompt("Which Wikipedia has an article on the same subject?"))', 'i-wiki'); } } if (window.addEventListener) window.addEventListener("load", add_tabs, false); else if (window.attachEvent) window.attachEvent("onload", add_tabs); function addtab(tabs, url, name, id){ var na = document.createElement('a'); na.href = url; na.id = id; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.appendChild(na); tabs.appendChild(li); return li; } /////////////////////////////////////////////////////////////////// // AutoAFD by Korath // This needs to change depending on skin used. ////////////////////////////////////////////////////////////////// function add_link2(url, name) { var na = document.createElement('a'); na.setAttribute('href', url); na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.appendChild(na); var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; tabs.appendChild(li); } function strip_namespace(target) { var colon = target.indexOf(':'); if (colon != -1) { var spaces = new Array('User', 'Wikipedia', 'Image', 'MediaWiki', 'Template', 'Help', 'Category'); 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; } function afd() { document.editform.wpTextbox1.value = '{' + '{' + 'subst:afd}}\n' + document.editform.wpTextbox1.value; document.editform.wpSummary.value = 'afd'; var target = document.editform.action; target = target.substring(target.indexOf('title=') + 6, target.lastIndexOf('&action=submit')); var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); var date = new Date(); date = date.getUTCFullYear() + '_' + months[date.getUTCMonth()] + '_' + date.getUTCDate(); var pagename = strip_namespace(target); window.open('/w/index.php?title=Wikipedia:Articles_for_deletion/' + pagename + '&action=edit&fakeaction=afdsub&faketarget=' + target, 'Afd ' + unescape(target), 'status,toolbar,location,menubar,directories,resizeable,scrollbars'); window.open('/w/index.php?title=Wikipedia:Articles_for_deletion/Log/' + date + '&action=edit&fakeaction=afdlist&faketarget=' + pagename, 'AfdLog ' + unescape(target), 'status,toolbar,location,menubar,directories,resizeable,scrollbars'); } function autoafd() { if (document.title.indexOf('Editing ') == 0) { var action = ''; var target = ''; if (location.search) { var l = location.search.substring(1).split('&'); for (var i = 0; i < l.length; ++i) { var eq = l[i].indexOf('='); var name = l[i].substring(0, eq); if (name == 'fakeaction') action = l[i].substring(eq + 1); else if (name == 'faketarget') target = unescape(l[i].substring(eq + 1)).replace(/_/g, ' '); } } if (action == 'afdlist') { document.editform.wpTextbox1.value += '{{' + 'subst:afd3|pg=' + target + '}}\n'; document.editform.wpSummary.value = '[[Wikipedia:Articles for deletion/' + target + ']]'; } else if (action == 'afdsub') { if (document.editform.wpTextbox1.value.length > 0) { target = document.editform.action; target = unescape(target.substring(target.indexOf('title=') + 6, target.lastIndexOf('&action=submit'))).replace(/_/g, ' '); window.alert("There's an old afd at the default location already.\n\n" + 'Please either move it out of the way (and update existing links to it), or file the Afd by hand in another location (such as [[' + target + ' (2)]]).'); } else document.editform.wpTextbox1.value += '{' + '{' + 'subst:afd2|pg=' + target + '|text=' + '}' + '}' + '-- ~' + '~' + '~' + '~\n' + '\n*\'\'\' \'\'\'\n*\'\'\' \'\'\'\n*\'\'\' \'\'\'\n'; } else add_link2('javascript:afd()', 'Afd'); } } if (window.addEventListener) window.addEventListener('load', autoafd, false); else if (window.attachEvent) window.attachEvent('onload', autoafd); // Adds a "blocklog" tab and fills in the username field on Special:Blockip, if a "&faketarget=username" is present. function do_blockip_stuff() { // focus on Reason field document.getElementsByName('wpBlockReason')[0].focus(); // Look for a &faketarget= for the username/ip var l = location.search.substring(1).split('&'); var target = ''; for (var i = 0; i < l.length; ++i) { var n = l[i].indexOf('='); if (l[i].substring(0, n) == 'faketarget') { target = l[i].substring(n + 1); break; } } if (target == '') return; // put account name in "IP Address/username" field var addr = document.getElementsByName('wpBlockAddress')[0]; addr.value = unescape(target); // add "blocklog" tab var c1 = document.getElementById('column-one'); var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0]; addlilink(tabs, '/wiki/Special:Log/block?page=User:' + target, 'blocklog'); } // Opens the block log in the current window, and Special:Blockip in a popup. // Width, height, top, and left are chosen for a 1600x1200 display. //function blockpage_and_log(target) //{ // window.open('Special_Blockip.html?foo=blarg&faketarget=' + target, 'Block', 'width=1600,height=600,top=600,left=0'); // document.location.href = 'http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=block&user=&page=User%3A' + target; //} // Adds "block" and "blocklog" tabs to User: and User talk: pages. function add_block_tab() { var c1 = document.getElementById('column-one'); var tabs = c1.getElementsByTagName('div')[0].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 addlilink(tabs, '/wiki/Special:Blockip/' + editlk, 'block'); // To open the block page and block log simultaneously, replace the above line with: // addlilink(tabs, 'javascript:blockpage_and_log("' + editlk + '")', 'Block'); // and uncomment the blockpage_and_log() function above. // add "blocklog" tab addlilink(tabs, '/w/index.php?title=Special%3ALog&type=block&user=&page=User%3A' + editlk, 'blocklog'); } function do_onload() { 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(); } //From User:Func if (window.addEventListener) window.addEventListener("load", do_onload, false); else if (window.attachEvent) window.attachEvent("onload", do_onload); if ( document.createElement && window.addEventListener ) { function SoFixItInit() // pre-load, (don't want to slow down loading of article's content, though) { } function SoFixItLoad() // post-load { UserMenu = new PortletMenu( 'p-personal' ); PageMenu = new PortletMenu( 'p-cactions' ); NavMenu = new PortletMenu( 'p-navigation' ); //ToolMenu = new PortletMenu( 'p-tb' ); // This is inefficient and not particularly robust. // This comes first, I want this link to come up as // fast as possible. // function GetByClass( sElem, sClass ) { var i, a2 = [], a = document.getElementsByTagName( sElem ); for ( i = 0; i < a.length; i++ ) if ( a[ i ].className == sClass ) a2.push( a[ i ] ); return a2; } var a, td = GetByClass( 'td', 'diff-otitle' ); if ( ( td = td[ 0 ] ) && ( a = td.getElementsByTagName( 'a' )[ 0 ] ) ) a.href = a.href + '&action=edit'; // need to change text, later var userName = UserMenu.getText( 'pt-userpage' ); // personal (top-most) menu // // Celestianpower Háblame Prefs Watchlist Contribs Kate VAN ESP Log out <UTCdate> // UserMenu.setText( 'pt-mytalk' , 'Talk' ); UserMenu.setText( 'pt-preferences', 'Prefs' ); UserMenu.setText( 'pt-watchlist' , 'Watchlist' ); UserMenu.setText( 'pt-mycontris' , 'Contribs' ); UserMenu.setText( 'pt-logout' , 'Log out' ); // UserMenu.setHref( 'pt-mycontris', 'http://en.wikipedia.org/w/index.php?title=Special:Contributions&target=' + userName + '&offset=0&limit=500' ); // // // it seems there is a stylesheet that makes them lowercase // // ok, the lowercased menu items are starting to really bug me: // document.getElementById( 'p-personal' ).getElementsByTagName( 'ul' )[0].style.textTransform = 'none'; // UserMenu.insertBefore( 'pt-stat', 'pt-esp', 'ESP', 'irc://irc.freenode.net/wikipedia-esperanza' ); UserMenu.insertBefore( 'pt-esp', 'pt-vandal', 'VAN', 'irc://irc.freenode.net/wikipedia-en-vandalism' ); UserMenu.insertBefore( 'pt-utc', 'pt-kate', 'Kate', 'javascript:void InlineKate( "' + userName + '" )' ); if(document.getElementById('ca-edit')) document.getElementById('ca-edit').firstChild.innerHTML = 'Edit'; // so I always know what time it is in UTC land: // UserMenu.append( 'pt-utc', UTCTime(), 'javascript:void UserMenu.setText("pt-utc",UTCTime())' ); // article-actions menu, (the "tabs") // if ( PageMenu[ 'ca-history' ] ) // theory: if it has a history tab, then it's purgable { PageMenu.insertBefore( 'ca-history', 'ca-lastdiff', 'Last diff', PageMenu.getHref( 'ca-history' ).replace( /action=history/, 'diff=0' ) ); PageMenu.append( 'ca-purge', 'Purge', PageMenu.getHref( 'ca-history' ).replace( /action=history/, 'action=purge' ) ); PageMenu.setText( 'ca-edit' , 'Edit' ); PageMenu.setText( 'ca-history' , 'History' ); PageMenu.setText( 'ca-delete' , 'Delete' ); } var x = 1; NavMenu.append( 'n-' + x++, 'monobook.js', 'http://en.wikipedia.org/w/index.php?title=User:' + userName + '/monobook.js&action=edit' ); NavMenu.append( 'n-' + x++, 'Vandalism Fighter', 'http://www.csclub.uwaterloo.ca/~dawill03/cdvf/vf.jar' ); NavMenu.append( 'n-' + x++, 'Wiktionary', 'http://en.wiktionary.org/wiki/Special:Watchlist'); NavMenu.append( 'n-' + x++, 'Snicket WikiCity', 'http://snicket.wikicities.com/wiki/Special:Recentchanges' ); NavMenu.append( 'n-' + x++, 'AfDs to be closed', 'http://en.wikipedia.org/wiki/Wikipedia:Articles_for_deletion/Old' ); } function PortletMenu( id ) // constructor { this.menu = document.getElementById( id ); this.list = this.menu.getElementsByTagName( 'ul' )[ 0 ]; // bypass "<h5>Views</h5>", etc. // sigh...as far as I can figure, there is empty whitespace being treated // as TextNodes.... // var LIs = this.list.getElementsByTagName( 'li' ); for ( var i = 0; i < LIs.length; i++ ) { this[ LIs[ i ].id ] = LIs[ i ]; } this.newItem = function( id, txt, url ) { var li = document.createElement( 'li' ); li.id = id; var a = document.createElement( 'a' ); a.href = url; a.appendChild( document.createTextNode( txt ) ); li.appendChild( a ); this[ id ] = li; // watch this!!! return li; } this.append = function( id, txt, url ) { this.list.appendChild( this.newItem( id, txt, url ) ); } this.insertBefore = function( old, id, txt, url ) { this.list.insertBefore( this.newItem( id, txt, url ), this[ old ] ); } // the ByTagName here is a bit annoying, but in Safari, I was picking // up TextNodes by using this[ id ].firstChild.firstChild // this.getText = function( id ) { return this[ id ].getElementsByTagName( 'a' )[ 0 ].firstChild.data } this.setText = function( id, txt ) { this[ id ].getElementsByTagName( 'a' )[ 0 ].firstChild.data = txt } this.getHref = function( id ) { return this[ id ].getElementsByTagName( 'a' )[ 0 ].href } this.setHref = function( id, url ) { this[ id ].getElementsByTagName( 'a' )[ 0 ].href = url } // I add em as I need em.... } function InlineKate( user ) { var kate = 'http://tools.wikimedia.de/~kate/cgi-bin/count_edits?user=' + user + '&dbname=enwiki'; var div = document.createElement( 'div' ); div.id = 'inlineKateDiv'; div.style.position = 'absolute'; div.style.zIndex = 1000; div.style.left = '20px'; div.style.top = '20px'; div.style.backgroundColor = '#FFFFFF'; div.style.borderStyle = 'solid'; div.style.borderWidth = ' medium'; div.style.borderColor = '#000000'; var top = document.createElement( 'div' ); top.id = 'inlineKateTop'; top.style.textAlign = 'right'; top.style.margin = '8px'; top.style.backgroundColor = '#DDDDDD'; var a = document.createElement( 'a' ); a.appendChild( document.createTextNode( "Go to Kate's" ) ); a.href = kate; a.target = '_parent'; a.style.margin = '8px'; top.appendChild( a ); a = document.createElement( 'a' ); a.appendChild( document.createTextNode( 'Close' ) ); a.href = "javascript:void RemoveNode('inlineKateDiv')"; a.style.margin = '8px'; top.appendChild( a ); div.appendChild( top ); var iframe = document.createElement( 'iframe' ); iframe.id = 'inlineKateBot'; iframe.style.width = '300px'; iframe.style.height = '400px'; iframe.style.margin = '8px'; iframe.style.borderStyle = 'solid'; iframe.style.borderWidth = 'thin'; iframe.style.borderColor = '#000000'; iframe.src = kate; div.appendChild( iframe ); document.body.appendChild( div ); } function RemoveNode( id ) { var node = document.getElementById( id ) node.parentNode.removeChild( node ); } function UTCTime() { // Get a date stamp for the time in UTC-land. // // for the future: a format arg // var s = '', d = new Date(), a = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' '); return d.getUTCDate() + ' ' + a[ d.getUTCMonth() ] + ' ' + d.getUTCFullYear() + ' ' + ( '0' + d.getUTCHours() ).substr( -2 ) + ':' + ( '0' + d.getUTCMinutes() ).substr( -2 ) + ' ' + 'UTC'; } SoFixItInit(); window.addEventListener( 'load', SoFixItLoad, false ); } function NUPatrol() { if ( ( window.location.href.indexOf( 'Special%3ALog&type=newusers' ) == -1 ) && ( window.location.href.indexOf( 'Special:Log/newusers' ) == -1 ) ) return; // make more robust??? var items, item, i, links, user, name, talk, contribs, insertLoc, link; items = document.getElementById( 'bodyContent' ).getElementsByTagName( 'ul' )[ 0 ].getElementsByTagName( 'li' ); function NewLink( txt, url, plainlinks, linkColor ) { var a = document.createElement( 'a' ); a.appendChild( document.createTextNode( txt ) ); a.href = url; if ( plainlinks ) a.className = 'plainlinks'; if ( linkColor ) { if ( typeof linkColor == "string" ) a.style.color = linkColor; else a.style.color = '#FF0000'; // old default behavior } return a; } for ( i = 0; i < items.length; i++ ) { item = items[ i ]; links = item.getElementsByTagName( 'a' ); user = links[ 0 ]; name = user.firstChild.nodeValue; talk = links[ 2 ]; talk.firstChild.nodeValue = 'talk'; // lowercase 'Talk' for consistency contribs = links[ 3 ]; insertLoc = user.nextSibling; // ' newusers ' item.insertBefore( document.createTextNode( ' ( ' ), insertLoc ); item.insertBefore( talk, insertLoc ); item.insertBefore( document.createTextNode( ', ' ), insertLoc ); item.insertBefore( contribs, insertLoc ); item.insertBefore( document.createTextNode( ', ' ), insertLoc ); item.insertBefore( NewLink( 'actions', '/w/index.php?title=Special%3ALog&user=' + name, true, '#000088' ), insertLoc ); item.insertBefore( document.createTextNode( ', ' ), insertLoc ); item.insertBefore( NewLink( 'blocks', '/w/index.php?title=Special%3ALog&type=block&page=User%3A' + name, true, '#008800' ), insertLoc ); item.insertBefore( document.createTextNode( ', ' ), insertLoc ); item.insertBefore( NewLink( 'is blocked?', '/wiki/Special:Ipblocklist?action=search&ip=' + name, true, '#888800' ), insertLoc ); item.insertBefore( document.createTextNode( ', ' ), insertLoc ); item.insertBefore( NewLink( 'do block!', '/w/index.php?title=Special:Blockip&ip=' + name, true, '#880000' ), insertLoc ); item.insertBefore( document.createTextNode( ' )' ), insertLoc ); item.removeChild( insertLoc.nextSibling ); // should remove the span item.removeChild( insertLoc ); // should remove ' newusers ' text } } if ( window.addEventListener ) window.addEventListener( 'load', NUPatrol, false ); else if ( window.attachEvent ) window.attachEvent( 'onload', NUPatrol ); //</nowiki> /////////////////////////////////////////////////////////////////// //////A script I am helping [[User:Where|Where]] test////////////// /////////////////////////////////////////////////////////////////// //Conflicts with force edit summary script! //Conflicts with force edit summary script! var scIndex = 0; var scKeys = new Array(); var scValues = new Array(); function scFormSubmit() { var i=0 var textArea = document.getElementById("wpTextbox1"); var text = textArea.value; while (i<scIndex) { text = text.replace(scKeys[i], scValues[i]); ++i; } textArea.value = text; } addOnloadHook(function() { if (document.title.indexOf("Editing ") != 0) {return;} document.getElementById("wpSave").onclick = scFormSubmit; document.getElementById("wpPreview").onclick = scFormSubmit; document.getElementById("wpDiff").onclick = scFormSubmit; //TODO: make it work with previews too! }); addOnloadHook(function() { if (document.title.indexOf("Editing ") != 0) {return;} var textArea = document.getElementById("wpTextbox1"); var text = textArea.value; var re = /<!--\[\[User:Where\/sigContract\]\];(.*)-->.*<!--ESC:(.*)-->/g; var lastIndex = 0; /* while (1) { var textSubstr = text.substr(lastIndex); alert(lastIndex); alert(textSubstr); //TODO: remove var newIndex = textSubstr.search(re); alert("newindex:" + newIndex); if (newIndex == -1) { break; } lastIndex += newIndex+1;*/ text = text.replace(re, function(str, p1, p2, offset, s) { // alert("In replacement function"); if (p1 == p2) { var newString = "-[[User:" + p1 + "|" + p1 + "]]"; scKeys[scIndex] = newString; scValues[scIndex] = str; ++scIndex; return newString; } else { return str; } }); //} textArea.value = text; }); function addGreetLinks() { var guff='&autoclick=wpSave&autosummary=Welcome!&preload=User%3AILovePlankton%2Fwelcome&editintro=Template%3AThisisnotatemplate§ion=new&create=Welcome'; var lis=document.getElementById('content').getElementsByTagName('li'); for (var i=0; i<lis.length; ++i) { var as=lis[i].getElementsByTagName('a'); var greet=as[1].cloneNode(true); greet.removeChild(greet.childNodes[0]); greet.appendChild(document.createTextNode('greet')); greet.href += '&action=edit' + guff; greet.removeAttribute('class'); as[1].parentNode.appendChild(document.createTextNode(' ')); as[1].parentNode.appendChild(greet); } } addOnloadHook(function(){if (/title=Special(%3A|:)Log&type=newusers/.test(document.location.href)){addGreetLinks();};});