User:Pekaje/moretabs.js
Appearance
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. |
![]() | Documentation for this user script can be added at User:Pekaje/moretabs. |
function addImageTagger()
{
if(wgCanonicalNamespace == "Image" && wgAction == "edit")
{
mw.util.addPortletLink("p-interaction", "javascript:tagReduce()", "Q. Rescale Image", "pekaje-id1", "Needs rescaling", "q", document.getElementById("n-About-Wikipedia"));
mw.util.addPortletLink("p-interaction", "javascript:tagReduced()", "A. Mark as rescaled", "pekaje-id2", "Is rescaled", "a", document.getElementById("n-About-Wikipedia"));
mw.util.addPortletLink("p-interaction", "javascript:rationaleBoilerplate()", "Z. Fair use template", "pekaje-id3", "Adds the fair use rationale template", "z", document.getElementById("n-About-Wikipedia"));
mw.util.addPortletLink("p-tb", "http://en.wikipedia.org/wiki/User:Pekaje/rationales", "Standard rationale content", "pekaje-id4", "", "", document.getElementById("t-whatlinkshere"));
}
}
function rationaleBoilerplate()
{
var tl1="{"+"{";
var tl2="}"+"}";
var nl="\n";
var text = document.editform.wpTextbox1;
text.value = text.value + nl + "== Fair use rationale for [[]] ==";
text.value = text.value + nl + tl1 + "Non-free media rationale";
text.value = text.value + nl + "|Description=";
text.value = text.value + nl + "|Source=";
text.value = text.value + nl + "|Portion=";
text.value = text.value + nl + "|Resolution=";
text.value = text.value + nl + "|Purpose=";
text.value = text.value + nl + "|Replaceability=";
text.value = text.value + nl + "|other_information=";
text.value = text.value + nl + tl2;
document.editform.wpSummary.value = "Fair use rationale added";
}
function tagReduced()
{
replaceTag("Non-free reduce","subst:furd");
replaceTag("FairUseReduce","subst:furd");
replaceTag("Fairusereduce","subst:furd");
replaceTag("Fair Use Reduce","subst:furd");
replaceTag("Fair use reduce","subst:furd");
replaceTag("Reduce size","subst:furd");
replaceTag("Reduce","subst:furd");
// Case insensitive on first letter ... Must fix this with regex later
replaceTag("non-free reduce","subst:furd");
replaceTag("fairUseReduce","subst:furd");
replaceTag("fairusereduce","subst:furd");
replaceTag("fair Use Reduce","subst:furd");
replaceTag("fair use reduce","subst:furd");
replaceTag("reduce size","subst:furd");
replaceTag("reduce","subst:furd");
document.editform.wpSummary.value = "Rescaled for fair use";
document.editform.wpMinoredit.checked = true;
document.editform.wpWatchthis.checked = true;
}
function tagReduce()
{
addTag("non-free reduce", "top");
document.editform.wpSummary.value = "Needs to be rescaled for fair use";
document.editform.wpMinoredit.checked = true;
}
function addTag(tag, place)
{
var text = document.editform.wpTextbox1;
if(place == "top")
{
text.value = "{" + "{" + tag + "}" + "}\n" + text.value;
}
else
{
text.value = text.value + "\n{" + "{" + tag + "}" + "}";
}
}
function replaceTag(oldtag, newtag)
{
var tl1="{"+"{";
var tl2="}"+"}\n";
var fulloldtag=tl1+oldtag+tl2;
var fullnewtag=tl1+newtag+tl2;
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(fulloldtag,fullnewtag);
}
$(addImageTagger);