User:Luk/Easy db.js
Appearance
< User:Luk
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
This user script seems to have a documentation page at User:Luk/Easy db. |
//<pre><nowiki>
//This file is released under GFDL.
//Please leave the following line
//[[user:Where/easy db]]
//Start db script
$(function()
{
//check if called from deletion request
if (document.title.indexOf("Editing ") != -1)
{
if (document.URL.lastIndexOf("&fakeaction=huff") == -1)
return;
// check if the page exists
if (wgCurRevisionId == false)
{
alert("The page has already been deleted.");
return;
}
if (document.URL.lastIndexOf("&reason=reply") != -1)
{
var type = prompt("Enter reply diff");
if (type == null)
return;
var f = document.editform, t = f.wpTextbox1;
t.value = t.value + "\n{{subst:User:Luk/s|1=" + type + "|subst=subst:}}";
f.wpSummary.value = "JS: replied on this user's talk page";
return;
}
if (document.URL.lastIndexOf("&reason=off") != -1)
{
var type = prompt("Enter criteria for speedy deletion, e.g. A1, G3");
if (type == null)
return;
var f = document.editform, t = f.wpTextbox1;
t.value = "{{db-" + type.toLowerCase() + "}}\n" + t.value;
f.wpSummary.value = "JS: Requesting speedy deletion ([[WP:CSD#" + type + "|CSD " + type.toUpperCase() + "]])";
f.wpWatchthis.checked = true;
f.wpSave.click();
return;
}
else if (document.URL.lastIndexOf("&reason=on") != -1)
{
var type = prompt("Enter reason for speedy deletion");
if (type == null)
return;
var f = document.editform, t = f.wpTextbox1;
t.value = "{{db|" + type + "}}\n" + t.value;
f.wpSummary.value = "JS: Requesting speedy deletion";
f.wpWatchthis.checked = true;
f.wpSave.click();
return;
}
else if (document.URL.lastIndexOf("&reason=cv") != -1)
{
var type = prompt("Enter URL of the copyright violation", "http://");
if (type == null)
return;
var f = document.editform, t = f.wpTextbox1;
t.value = "{{db-copyvio|url=" + type + "}}\n" + t.value;
f.wpSummary.value = "JS: Requesting speedy deletion: copyright violation of "+type;
f.wpWatchthis.checked = true;
f.wpSave.click();
return;
}
else if (document.URL.lastIndexOf("&reason=prod") != -1)
{
var type = prompt("Prod reason", "[[WP:NOT|Wikipedia is NOT]] ");
if (type == null)
return;
var f = document.editform, t = f.wpTextbox1;
t.value = "{{subst:prod|" + type + "}}\n" + t.value;
f.wpSummary.value = "JS: Proposing deletion: "+type;
f.wpWatchthis.checked = true;
f.wpSave.click();
window.open("/w/index.php?title=User:Luk/Prod%20log&action=edit&fakeaction=huff&reason=logprod&page="+wgPageName+"&logreason="+type).blur();
return;
}
else if (document.URL.lastIndexOf("&reason=logprod") != -1)
{
var f = document.editform, t = f.wpTextbox1;
var article = getURLParam("page");
var reason = getURLParam("logreason");
t.value = t.value + "\n* ~~~~~ [["+article+"]] - "+reason;
f.wpSummary.value = "proded [["+article+"]]";
f.wpSave.click();
window.close();
return;
}
}
if (wgCanonicalNamespace == "Special")
return;
if (wgPageName == "User_talk:Luk")
{
mw.util.addPortletLink("p-cactions", "javascript:reply()", "reply", "ca-reply", "Reply URL", "");
}
else
{
// mw.util.addPortletLink("p-cactions", "javascript:easyDb(0)", "db (csd)", "ca-db0", "Request speedy deletion according to WP:CSD", "");
// mw.util.addPortletLink("p-cactions", "javascript:easyDb(1)", "db (reason)", "ca-db1", "Request speedy deletion with reason", "");
mw.util.addPortletLink("p-cactions", "javascript:easyDb(2)", "copyvio", "ca-db2", "Request speedy deletion for copyvio", "");
mw.util.addPortletLink("p-cactions", "javascript:easyDb(3)", "prod", "ca-db3", "prod an article", "");
}
});
function easyDb(n)
{
var title = wgPageName.replace("&", "%26").replace("+", "%21");
if (n == 0)
{
//edit page
location.assign("/w/index.php?title=" + title+ "&action=edit&fakeaction=huff&reason=off");
}
if (n == 1)
{
//edit page
location.assign("/w/index.php?title=" + title+ "&action=edit&fakeaction=huff&reason=on");
}
if (n == 2)
{
// copyvio
var type = prompt("Enter URL of the copyright violation", "http://");
if (type == null)
return;
var template = "{{subst:sd-copyvio|"+ wgTitle +"|url="+type+"|header=1}} ~~~~";
prompt("Formatted template:", template);
//go to the history
location.assign("/w/index.php?title=" + title+ "&action=history");
}
if (n == 3)
{
//edit page
location.assign("/w/index.php?title=" + title+ "&action=edit&fakeaction=huff&reason=prod");
}
}
function reply()
{
var title = wgPageName.replace("&", "%26");
location.assign("/w/index.php?title=" + title+ "&action=edit&fakeaction=huff&reason=reply");
}
function getURLParam(strParamName){
var strReturn = "";
var strHref = window.location.href;
if ( strHref.indexOf("?") > -1 ){
var strQueryString = strHref.substr(strHref.indexOf("?"));
var aQueryString = strQueryString.split("&");
for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
if (
aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
var aParam = aQueryString[iParam].split("=");
strReturn = aParam[1];
break;
}
}
}
return unescape(strReturn);
}
//End db script
//</nowiki></pre>