User:Glen/monobook/deleting.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.
//<pre><nowiki> //Auto AFD Lister-------------- // This needs to change depending on skin used. 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 prod() { var reason = prompt('Reason:'); document.editform.wpTextbox1.value = '{{subst:Prod|' + reason + '}}\n' + document.editform.wpTextbox1.value; document.editform.wpSummary.value = 'This page has been proposed for deletion and will be deleted in 5 days if no one objects.'; } function vfd() { document.editform.wpTextbox1.value = '{{' + 'subst:afd}}\n' + document.editform.wpTextbox1.value; document.editform.wpSummary.value = 'afd'; var target = document.title.split('Editing ')[1].split(' - ')[0]; 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/' + URLEncoding(pagename) + '&action=edit&fakeaction=vfdsub&faketarget=' + URLEncoding(target), 'Afd ' + 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=' + URLEncoding(pagename), 'AfdLog ' + 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 += '{{' + 'Wikipedia:Articles for deletion/' + target + '}}\n'; document.editform.wpSummary.value = '[[Wikipedia:Articles for deletion/' + target + ']]'; } else if (action == 'vfdsub') { if (document.editform.wpTextbox1.value.length > 0) { 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 += '===[[' + target + ']]===\n' + '{{REMOVE THIS TEMPLATE WHEN CLOSING THIS AfD|{{{cat}}}}}\n\n' + ':{{la|' + target + '}}\n' + 'Reason for nom ~~' + '~~\n*\n*\n*\n'; } else ; } } //END //AFD Closer---------------- //this helps automate AfD closing by adding a 'close' tab to AfD debates //written by [[User:Johnleemk]] based on [[Wikipedia:WikiProject User scripts/Scripts/test-n.js]] by [[User:Celestianpower]] function result() { var close = prompt("Result of debate?") var f = document.editform, t = f.wpTextbox1; t.value = "{{subst:" + "at" + "}} '''" + close + "'''. " + "~" + "~" + "~" + "~" + '\n' + '\n' + t.value; if (t.value.length > 0) t.value += '\n'; t.value += "{{subst:" + "ab" + "}}"; f.wpSummary.value = "Closing debate; result was " + close; } function relist() { var f = document.editform, t = f.wpTextbox1; if (t.value.length > 0) t.value += '\n'; t.value += "{{subst:" + "relist" + "|~" + "~" + "~" + "~}}"; f.wpSummary.value = "Relisting debate"; } function keep() { var date = prompt("Nomination was made when?") var votepage = prompt("Vote page is? (Enter 'd' for default.)") var f = document.editform, t = f.wpTextbox1; // If default votepage... if (votepage=="d") { var temp = document.editform.action.split("/w/index.php?title="); var temp = temp[1].split("&action=submit"); var temp = temp[0].substring(5); var votepage = temp; } t.value = "{{subst:" + "oldafdfull" + "|date=" + date + "|votepage=" + votepage + "}}" + '\n' + '\n' + t.value; f.wpSummary.value = "Article survived AfD"; } function tagnote(string) { if (!string){return;} var f = document.editform, t = f.wpTextbox1; t.value = "{{" + string + "}}" + "\n" + t.value; f.wpSummary.value = "Tagged: " + string; document.getElementById('wpMinoredit').checked=true; } function no_consensus() { var date = prompt("Nomination was made when?") var votepage = prompt("Vote page is? (Enter 'd' for default.)") var f = document.editform, t = f.wpTextbox1; // If default votepage... if (votepage=="d") { var temp = document.editform.action.split("/w/index.php?title="); var temp = temp[1].split("&action=submit"); var temp = temp[0].substring(5); var votepage = temp; } t.value = "{{subst:" + "oldafdfull" + "|date=" + date + "|result='''no consensus'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value; f.wpSummary.value = "Article survived AfD with no consensus"; } function redirect() { var date = prompt("Nomination was made when?") var redirect = prompt("Redirect to?") var votepage = prompt("Vote page is? (Enter 'd' for default.)") var f = document.editform, t = f.wpTextbox1; // If default votepage... if (votepage=="d") { var temp = document.editform.action.split("/w/index.php?title="); var temp = temp[1].split("&action=submit"); var temp = temp[0].substring(5); var votepage = temp; } t.value = "{{subst:" + "oldafdfull" + "|date=" + date + "|result='''redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value; f.wpSummary.value = "Article redirected to [[" + redirect + "]] as per AfD"; } function merge() { var date = prompt("Nomination was made when?") var redirect = prompt("Merge and redirect to?") var votepage = prompt("Vote page is? (Enter 'd' for default.)") var f = document.editform, t = f.wpTextbox1; // If default votepage... if (votepage=="d") { var temp = document.editform.action.split("/w/index.php?title="); var temp = temp[1].split("&action=submit"); var temp = temp[0].substring(5); var votepage = temp; } t.value = "{{subst:" + "oldafdfull" + "|date=" + date + "|result='''merge and redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value; f.wpSummary.value = "Article merged and redirected to [[" + redirect + "]] as per AfD"; } function other() { var date = prompt("Nomination was made when?") var result = prompt("Result was?") var votepage = prompt("Vote page is? (Enter 'd' for default.)") var f = document.editform, t = f.wpTextbox1; // If default votepage... if (votepage=="d") { var temp = document.editform.action.split("/w/index.php?title="); var temp = temp[1].split("&action=submit"); var temp = temp[0].substring(5); var votepage = temp; } t.value = "{{subst:" + "oldafdfull" + "|date=" + date + "|result='''" + result + "'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value; f.wpSummary.value = "AfDed; result was " + result; } addOnloadHook(add_afd_tabs) function add_afd_tabs() { var c1 = document.getElementById('column-one'); var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0]; // Only add for pages with the right string somewhere in the title if (document.title.indexOf("Editing Wikipedia:Articles for deletion/") != -1) { addTab("javascript:result()","close", "ca-afdcl", "Close AfD", ""); addTab("javascript:relist()","relist", "ca-afdrl", "Re-list AfD", ""); } if (document.title.indexOf("Editing Talk:") != -1) { var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; addlimenu(tabs, '(AfD)', 'afdtfunc'); var afdtfun = document.getElementById('afdtfunc').getElementsByTagName('ul')[0]; addlilink(afdtfun, 'javascript:keep()',"K", ''); addlilink(afdtfun, 'javascript:no_consensus()','NC', ''); addlilink(afdtfun, 'javascript:redirect()',"R", ''); addlilink(afdtfun, 'javascript:merge()',"M", ''); if(document.getElementById('ca-delete')) { document.getElementById('ca-delete').firstChild.innerHTML = '<span style="color:red;">[d]</span>'; } if(document.getElementById('ca-move')) { document.getElementById('ca-move').firstChild.innerHTML = '[m]'; } if(document.getElementById('ca-watch')) { document.getElementById('ca-watch').firstChild.innerHTML = '[w]'; } if(document.getElementById('ca-unwatch')) { document.getElementById('ca-unwatch').firstChild.innerHTML = '[uw]'; } } } //END 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 + ']]'; } // } } } 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 + '/Articles' + '&action=edit&fakeaction=copyviolist&faketarget=' + pagename, 'status,toolbar,location,menubar,directories,resizeable,scrollbars'); } //END addOnloadHook(createtabs) function createtabs() { if (document.title.search(/Editing Wikipedia:Articles for creation\/.+ \(section\)/) ==0) { addTab("javascript:AfCresult(0)","acc", "ca-afc1", "Close AfC", ""); addTab("javascript:AfCresult(1)","rej", "ca-afc2", "Close AfC", ""); } } function AfCresult(type) { if (type==0) var add = '{{subst:afc top|accept}}'; else var add = '{{subst:afc top}}'; var txt = document.editform.wpTextbox1.value; if (txt.search('==\n') !=-1) { document.editform.wpTextbox1.value = txt.substring(0,txt.indexOf('==\n')) + '==\n' + add + '\n' + txt.substring(txt.indexOf('==\n') + 4); } else { document.editform.wpTextbox1.value = add + '\n' + document.editform.wpTextbox1.value; } txt = document.editform.wpTextbox1.value; if (txt.indexOf('<!--Place the {{afc b}} tags above this line-->') !=-1) { document.editform.wpTextbox1.value = txt.split('<!--Place the {{afc b}} tags above this line-->')[0] + '\n{{subst:afc b}}' + '\n<!--Place the {{afc b}} tags above this line-->'; } else { document.editform.wpTextbox1.value += '\n{{subst:afc b}}'; } } addOnloadHook(deltabs) function deltabs() { if (document.title.indexOf('Editing ') == -1 || document.title.indexOf('User:') != -1 || document.title.indexOf(' talk:') != -1 || document.title.indexOf('MediaWiki:') != -1 || document.title.indexOf('Portal:') != -1 || document.title.indexOf('Help:') != -1 || document.title.indexOf('Wikipedia:') != -1 || document.title.indexOf('Image:') != -1 || document.title.indexOf('Template:') != -1 || document.title.indexOf('Category:') != -1){return;} var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; addlimenu(tabs, '{{note}}', 'delfunc'); var delfunc = document.getElementById('delfunc').getElementsByTagName('ul')[0]; addlilink(delfunc, 'javascript:tagnote("WPBiography|living=yes")', 'BLP', ''); addlilink(delfunc, 'javascript:tagnote("cleanup")', 'Clean', ''); addlilink(delfunc, 'javascript:tagnote("tone")', 'Tone', ''); addlilink(delfunc, 'javascript:tagnote("verify")', 'Verify', ''); addlilink(delfunc, 'javascript:tagnote("unreferenced")', 'Cite', ''); addlilink(delfunc, 'javascript:tagnote("POV-check")', 'POV', ''); addlilink(delfunc, 'javascript:tagnote("accuracy")', 'Acc.', ''); addlilink(delfunc, 'javascript:tagnote("advert")', 'Adv.', ''); addlilink(delfunc, 'javascript:prod()', 'PfD', ''); addlilink(delfunc, 'javascript:vfd()', 'AfD', ''); addlilink(delfunc, 'javascript:copyvio()', 'c-vio', ''); } if (window.addEventListener) window.addEventListener('load', autovfd, false); else if (window.attachEvent) window.attachEvent('onload', autovfd); addOnloadHook(morelinks); /*** Make old AfD's appear or disappear - from AmiDaniel's monobook ***/ 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 = ''; } function morelinks() { var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; if(document.title.indexOf("Wikipedia:Articles for deletion") == 0 && location.href.indexOf('&action=') == -1) { 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']; } } //</pre></nowiki>end AfD closing script