User:Dycedarg/easyprod.js
From Wikipedia, the free encyclopedia
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() { //check if called from deletion request if (document.title.indexOf("Editing ") != -1) { if (document.URL.lastIndexOf("&fakeaction=prod") != -1) { var staticreason=false; if (typeof(customreason) != 'undefined') staticreason = true; if (document.URL.lastIndexOf("¬ify=off") != -1) { var reason; if (staticreason) reason=customreason; else reason = prompt("Enter reason for proposed deletion"); if (reason == null) return; var f = document.editform, t = f.wpTextbox1; t.value = "{"+"{subst:prod|" + reason + "}}\n" + t.value; f.wpSummary.value = "Proposing page for deletion"; f.wpSave.click(); return; } else if (document.URL.lastIndexOf("¬ify=on") != -1) { var reason; if (staticreason) reason=customreason; else reason = prompt("Enter reason for proposed deletion"); if (reason == null) return; var f = document.editform, t = f.wpTextbox1; var pagename=wgPageName.replace(/_/g, ' '); t.value = "{"+"{subst:prod|" + reason + "}}\n" + t.value; f.wpSummary.value = "Proposing page for deletion"; f.wpSave.click(); userTalkXML = sajax_init_object(); userTalkXML.overrideMimeType('text/xml'); userTalkXML.onreadystatechange = easyProdNotifyCallback; userTalkXML.open('GET' , 'http://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles='+ pagename + '&rvprop=user&rvlimit=1&rvdir=newer&format=xml', true); userTalkXML.send(null); return; } } else if (document.URL.lastIndexOf("&fakeaction=notifyprod") != -1) { i=document.URL.lastIndexOf("&faketarget="); target=document.URL.substring(i+12).replace(/_/g, ' '); var notifycustom=false; var warning; if (typeof(customnotifytemplate) != 'undefined') notifycustom = true; var f = document.editform, t = f.wpTextbox1; if (notifycustom) warning=customnotifytemplate; else warning='prodwarning'; t.value = t.value + "{"+"{subst:"+warning+"|" + target + "}}--~~" + "~~\n"; f.wpSummary.value = "[[" + target + "]] has been proposed for deletion"; return; } else return; } if (wgCanonicalNamespace != "" && wgCanonicalNamespace != "User") return; var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; addlimenu(tabs, "Prod", "prod" ); addPortletLink("prod", "javascript:easyProd(1)", "Notify", "prod1", "Propose page for deletion and notify original author", ""); addPortletLink("prod", "javascript:easyProd(0)", "Don't notify", "prod0", "Propose page for deletion", ""); }); function easyProdNotifyCallback() { if ( userTalkXML.readyState != 4 ) return; var author = userTalkXML.responseXML.documentElement.getElementsByTagName('rev')[0].getAttribute('user'); window.open('/w/index.php?title=User_talk:' + author + '&action=edit&fakeaction=notifyprod&faketarget=' + wgPageName, 'Warning ' + unescape(wgPageName), 'location=no,toolbar=no,status=no,directories=no,scrollbars=yes,width=1200,height=800'); } function easyProd(n) { if (n == 0) { //edit page location.assign("/w/index.php?title=" + wgPageName + "&action=edit&fakeaction=prod¬ify=off"); } if (n == 1) { //edit page location.assign("/w/index.php?title=" + wgPageName + "&action=edit&fakeaction=prod¬ify=on"); } }