User:Lar/moretabs/monobook.js
From Wikipedia, the free encyclopedia
< User:Lar | moretabs
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> // must have brought DYK funcs in before calling this module as it depends on some of them // generate and return date in the form "June 11, 2006" function cur_date() { var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); var date = new Date(); var moDayStr = months[date.getUTCMonth()]+" "+date.getUTCDate(); var t = moDayStr; return t; } function cur_date_year() { var months2 = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); var date = new Date(); var yearStr = date.getUTCFullYear(); var MoDayStr = months2[date.getUTCMonth()]+" "+date.getUTCDate(); var t = MoDayStr+", "+yearStr; return t; } // for article talk page function afdresult() { var res = prompt("Result?","Keep - No Consensus"); if(!res) return; var afddate = prompt("Nomination date?",cur_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 += "{{oldafdfull|date=[[" + afddate + "]] [[{{subst:CURRENTYEAR}}]]|result='''" + res + "'''|votepage={{subst:PAGENAME}}}}"; 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"; // needed to shrink the page - rendering bug 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 = ""; // might as well put it back... document.getElementById('footer').style.display = ''; } // 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; } // appends msg to the currently-editted page, sets the summary to summ, // and marks or unmarks the Watch this page checkbox according to watch. // SAME AS ABOVE?? ... almost, one has optional \n the other is mandatory function add_del_tag(msg, summ, watch) { var f = document.editform, t = f.wpTextbox1; msg += '\n'; msg += t.value; t.value = msg; f.wpSummary.value = summ; f.wpWatchthis.checked = watch; } // do a newsletter delivery // edit summary should say // Delivery of [[WP:Beatles]] newsletter [[Wikipedia:WikiProject The Beatles/Outreach/Newsletter/Issue 005]] // payload should be // // == [[WP:Beatles|WikiProject The Beatles]] Newsletter, [[Wikipedia:WikiProject The Beatles/Outreach/Newsletter/Issue 003|Issue 3]], July 2006 == // {{subst:Wikipedia:WikiProject_The_Beatles/Outreach/Newsletter/Issue_003}} function newsletterDeliv() { var f = document.editform, t = f.wpTextbox1; t.value += "{{-}} \n{{subst:Wikipedia:WikiProject_The_Beatles/Outreach/Newsletter/Issue_008}}"; f.wpSummary.value = "[[WP:Beatles|WikiProject The Beatles]] Newsletter, " +"[[Wikipedia:WikiProject The Beatles/Outreach/Newsletter/Issue 008|Issue 8]], December 2006"; } // add a {{subst:unsigned2|00:49, 27 May 2006|Joe Random User}} // at the end of the current edit contents. // will have problems at the change in years since it depends on date.getUTCFullYear() function addUnsigned2() { // sample string to paste in is "18:32, 18 June 2006 FredUser" or "00:49, 27 May 2006 Timothy Usher " var date = new Date(); var idString = prompt("ID string?"); var f = document.editform, t = f.wpTextbox1; // a regexp for the date part of the string would be a better way to do this... //... but slicing on year should almost always work var pipeLoc= idString.indexOf(date.getUTCFullYear()); // assume 4 digit year, breaks after 9999 var idStringPiped= idString.substr(0,pipeLoc+4)+'|'+idString.substr(pipeLoc+5,idString.length); t.value += "{{subst:unsigned2|" + idStringPiped + "}}"; f.wpSummary.value = "add {{tl|Unsigned2}} using string:" + idString; } //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 += "{{subst:test" + number + "-n|" + page + "}} ~~~~"; f.wpSummary.value = "Your edits to [[" + page + "]]" document.editform.wpWatchthis.checked = false; } // adds various tabs and menu tabs function add_more_tabs() { var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; var username=document.getElementById("pt-userpage").textContent; // Only add for pages with "Editing User talk:" somewhere in the title if (document.title.indexOf("Editing User talk:") != -1) { addlimenu(tabs, 'Talk messages', 'talkm'); var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0]; addlilink(talkm,'javascript:updated_dyk()','DYK-Auth'); addlilink(talkm,'javascript:updated_dyk_nom()','DYK-Nom'); addlilink(talkm,'javascript:addUnsigned2()','Unsigned2'); addlilink(talkm,'javascript:newsletterDeliv()','Newsletter'); addlilink(talkm,'javascript:edit_summary_watch("{{subst:Welcome}} -- ~~~~", "Welcome to Wikipedia!", true, 1)','Welcome', ''); addlilink(talkm,'javascript:edit_summary_watch("{{subst:Anon}} -- ~~~~", "Welcome to Wikipedia!", true, 1)','Anon', ''); addlilink(talkm, 'javascript:testn(1)', 'Test1', ''); addlilink(talkm,'javascript:testn(2)','Test2', ''); addlilink(talkm,'javascript:testn("2a")','Test2a', ''); addlilink(talkm,'javascript:testn(3)','Test3', ''); addlilink(talkm,'javascript:edit_summary_watch("{{subst:Test4}} -- ~~~~", "Last warning", false, 1)','Test4', ''); addlilink(talkm,'javascript:edit_summary_watch("{{subst:Test5-n|24 hours|~~~~}}", "You have been blocked", false, 1)','Test5', ''); addlilink(talkm,'javascript:edit_summary_watch("{{subst:s/block1||24 hours|reason=vandalism|signature=~~~~}}", "You have been blocked", false, 1)','S/block', ''); addlilink(talkm,'javascript:edit_summary_watch("{{subst:bv}} -- ~~~~", "Vandalism", false, 1)','BV', ''); addlilink(talkm,'javascript:edit_summary_watch("{{subst:Vanity|}} -- ~~~~", "About the page you created", false, 1)','Vanity', ''); addlilink(talkm,'javascript:edit_summary_watch("{{subst:spam1}} -- ~~~~", "Adding links to Wikipedia", false, 1)','Spam1', ''); addlilink(talkm,'javascript:edit_summary_watch("{{subst:spam2}} -- ~~~~", "Spamming", false, 1)','Spam2', ''); addlilink(talkm,'javascript:edit_summary_watch("{{subst:spam3}} -- ~~~~", "Last warning for spamming", false, 1)','Spam3', ''); addlilink(talkm,'javascript:edit_summary_watch("{{subst:spam4}} -- ~~~~", "You have been blocked for spamming", false, 1)','Spam4', ''); addlilink(talkm,'javascript:edit_summary_watch("{{subst:rvfd|}} -- ~~~~", "{{rvfd}}", false, 1)','rvfd', ''); addlilink(talkm,'javascript:edit_summary_watch("{{subst:blanking}} -- ~~~~", "Blanking pages", false, 1)','blanking', ''); addlilink(talkm,'javascript:edit_summary_watch("{{subst:nothanks|}} -- ~~~~", "About your edits", false, 1)','nothanks', ''); addlilink(talkm,'javascript:edit_summary_watch("{{nothanks-sd|pg=page name|url=url of source}} -- ~~~~", "{{nothanks-sd}}", false, 1)','nothanks-sd', ''); } // Only add for pages with "Editing Talk:" somewhere in the title if (document.title.indexOf("Editing Talk:") != -1) { addlimenu(tabs, 'artTalk msgs', 'talkm'); var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0]; addlilink(talkm,'javascript:dyk_talk()','DYK'); addlilink(talkm,'javascript:afdresult()','AfDres'); addlilink(talkm,'javascript:addUnsigned2()','Unsigned2'); } // AfD tabs if(document.title.indexOf("Editing Wikipedia:Articles for deletion") != -1){ addlimenu(tabs, 'AfD actions', 'afda'); var afda = document.getElementById('afda').getElementsByTagName('ul')[0]; addlilink(afda,'javascript:addUnsigned2()','Unsigned2'); addlilink(afda, 'javascript:closevfd("Delete", "")', 'Delete', ''); addlilink(afda, 'javascript:closevfd("Speedy Delete", "")', 'SD', ''); addlilink(afda, 'javascript:closevfd("Keep", "")', 'Keep', ''); addlilink(afda, 'javascript:closevfd("Keep (No consensus)", "")', 'Keep, NC', ''); addlilink(afda, 'javascript:closevfd("Merge and Redirect", " to [[" + prompt("Merge and redirect to?") + "]]")', 'M&R', ''); addlilink(afda, 'javascript:closevfd("Redirect", " to [[" + prompt("Redirect to?") + "]]")', 'Redirect', ''); addlilink(afda, 'javascript:closevfd("Ttranswiki", " to " + prompt("Transwiki to?"))', 'Transwiki', ''); addlilink(afda, 'javascript:closevfd("Transwiki", " to Wiktionary")', 'WIKT', ''); addlilink(afda, 'javascript:closevfd(prompt("Result?"), "")', 'Other', ''); } if(document.title.indexOf("Wikipedia:Articles for deletion") ==0 ){ //Add show/hide closed AfDs 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']; } if (document.title.indexOf("Editing User:" + username + "/Status") == 0){ addlimenu(tabs, 'Change my status', 'mystatus'); var mystatus = document.getElementById('mystatus').getElementsByTagName('ul')[0]; addlilink(mystatus, 'javascript:edit_status("in")', 'In', ''); addlilink(mystatus, 'javascript:edit_status("out")', 'Out', ''); addlilink(mystatus, 'javascript:edit_status("around")', 'Around', ''); } if (document.title.indexOf("Block user") == 0) { addlilink(tabs, 'javascript:blockuser("{{username}}", "indefinite")', "username"); addlilink(tabs, 'javascript:blockuser("imposter", "indefinite")', "imposter"); addlilink(tabs, 'javascript:blockuser("please contact an administrator for verification purposes, as described on this page", "indefinite")', "verification"); addlilink(tabs, 'javascript:blockuser("vandalism only account", "indefinite")', "vandalism only"); addlilink(tabs, 'javascript:blockuser("{{wow}}", "indefinite")', "willy"); addlilink(tabs, 'javascript:blockuser("{{wic}}", "indefinite")', "communism"); addlilink(tabs, 'javascript:blockuser("{{3RR3}}", "24 hours")', "revert"); addlilink(tabs, 'javascript:blockuser("vandalism - AOL", "15 minutes")', "AOL") addlilink(tabs, 'javascript:blockuser("vandalism - shared IP", "3 hours")', "shared") addlilink(tabs, 'javascript:blockuser("vandalism - returning", "1 week")', "returning"); addlilink(tabs, 'javascript:blockuser("vandalism", "24 hours")', "vandalism"); } // if we are editing and it's SOME kind of talk page... // if ( (document.title.indexOf("Editing") ==0) && (document.title.indexOf("Talk") != -1) ) // { // addlimenu(tabs, 'any Talk', 'anytalkm'); // var anytalkm = document.getElementById('anytalkm').getElementsByTagName('ul')[0]; // addlilink(anytalkm,'javascript:addUnsigned2()','Unsigned2'); // } if (document.title.indexOf("Editing") != 0) { } } function closevfd(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; } /////////////////////////////////////////////////////////////////// // AutoVFD 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 vfd() { 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=vfdsub&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=vfdlist&faketarget=' + pagename, 'VfdLog ' + unescape(target), 'status,toolbar,location,menubar,directories,resizeable,scrollbars'); } function autovfd() { 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 == 'vfdlist') { document.editform.wpTextbox1.value += '{{' + 'subst:afd3|pg=' + target + '}}\n'; document.editform.wpSummary.value = '[[Wikipedia:Articles for deletion/' + target + ']]'; } else if (action == 'vfdsub') { 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 vfd at the default location already.\n\n" + 'Please either move it out of the way (and update existing links to it), or file the Vfd 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:vfd()', 'Afd'); } } /////////////////////////////////////////////////////////////////// // AutoCopyvio - Created by bmicomp from modified autovfd ////////////////////////////////////////////////////////////////// function copyvio() { document.editform.wpTextbox1.value = '{' + '{' + 'copyvio|url=}}'; document.editform.wpSummary.value = 'copyvio'; 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 = months[date.getUTCMonth()] + '_' + date.getUTCDate(); var datestring = date.getUTCFullYear() + '_' + months[date.getUTCMonth()] + '_' + date.getUTCDate(); var pagename = strip_namespace(target); window.open('/w/index.php?title=Wikipedia:Copyright_problems/' + datestring + '&action=edit&fakeaction=copyviolist&faketarget=' + pagename, 'status,toolbar,location,menubar,directories,resizeable,scrollbars'); } function autocopyvio() { 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 == 'copyviolist') { // var index = document.editform.wpTextbox1.value.lastIndexOf("\n==Footer=="); /* if (index == -1) { window.alert("Couldn't find footer\n\n"); } else { */ // var firsthalf = document.editform.wpTextbox1.value.substr(0,index); // var secondhalf = document.editform.wpTextbox1.value.substr(index); document.editform.wpTextbox1.value += '*[[' + target + ']] <span class="plainlinks">([http://en.wikipedia.org/{{localurl:' + target + '|action=history}} history] · [http://en.wikipedia.org/{{localurl:' + target + '|diff=0}} last edit])</span>' + ' from [' + '] ~' + '~~' + '~'; document.editform.wpSummary.value = 'Copyvio ' + '[[' + target + ']]'; } // } else add_link2('javascript:copyvio()', 'copyvio'); } } //</nowiki>