User:Super-Magician/QuickWarn.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:Super-Magician/QuickWarn. |
// Modified from Voice of All's non-admin RC patrol JavaScript
// <pre><nowiki>
// Quick warning definitions
function tnaddlilink(url, name)
{
var na = document.createElement('a');
na.setAttribute('href', url);
var txt = document.createTextNode(name);
na.appendChild(txt);
var li = document.createElement('li');
li.appendChild(na);
return li;
}
function testn(number)
{
var IPnote = '';
if (document.title.split(' - ')[0].split('.').length == 4)
{IPnote = "''If this is an [[IP address]], and it is shared by multiple users, ignore this warning if you did not make any [[Wikipedia:Vandalism|unconstructive]] edits.'' ";}
var varticle = '';
if (location.href.indexOf('&vanarticle=') != -1)
{varticle = unescape(location.href.split('&vanarticle=')[1].split('&')[0].replace(/(Image|Category):/i,':$1:'));}
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += "=== Regarding edits made during [[{{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}}]] [[{{subst:CURRENTYEAR}}]] ([[UTC]]) ===" + "\n" + "{{subst:" + "uw-test" + number + "|" + varticle + "|subst=subst:}} " + IPnote + "~" + "~" + "~" + "~";
f.wpSummary.value = "Adding notice:" + " {{uw-test" + number + "}}";
}
function vandn(number)
{
var IPnote = '';
if (document.title.split(' - ')[0].split('.').length == 4)
{IPnote = "''If this is an [[IP address]], and it is shared by multiple users, ignore this warning if you did not make any [[Wikipedia:Vandalism|unconstructive]] edits.'' ";}
var varticle = '';
if (location.href.indexOf('&vanarticle=') != -1)
{varticle = unescape(location.href.split('&vanarticle=')[1].split('&')[0].replace(/(Image|Category):/i,':$1:'));}
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += "=== Regarding edits made during [[{{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}}]] [[{{subst:CURRENTYEAR}}]] ([[UTC]]) ===" + "\n" + "{{subst:" + "uw-vandalism" + number + "|" + varticle + "|subst=subst:}} " + IPnote + "~" + "~" + "~" + "~";
f.wpSummary.value = "Adding notice:" + " {{uw-vandalism" + number + "}}";
}
function vandim()
{
var IPnote = '';
if (document.title.split(' - ')[0].split('.').length == 4)
{IPnote = "''If this is an [[IP address]], and it is shared by multiple users, ignore this warning if you did not make any [[Wikipedia:Vandalism|unconstructive]] edits.'' ";}
var varticle = '';
if (location.href.indexOf('&vanarticle=') != -1)
{varticle = unescape(location.href.split('&vanarticle=')[1].split('&')[0].replace(/(Image|Category):/i,':$1:'));}
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += "=== Regarding edits made during [[{{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}}]] [[{{subst:CURRENTYEAR}}]] ([[UTC]]) ===" + "\n" + "{{subst:" + "uw-vandalism4im" + "|" + varticle + "|subst=subst:}} " + IPnote + "~" + "~" + "~" + "~";
f.wpSummary.value = "Adding notice: {{uw-vandalism4im}}";
}
function warningn()
{
var IPnote = '';
if (document.title.split(' - ')[0].split('.').length == 4)
{IPnote = "''If this is an [[IP address]], and it is shared by multiple users, ignore this warning if you did not make any [[Wikipedia:Vandalism|unconstructive]] edits.'' ";}
var varticle = '';
if (location.href.indexOf('&vanarticle=') != -1)
{varticle = unescape(location.href.split('&vanarticle=')[1].split('&')[0].replace(/(Image|Category):/i,':$1:'));}
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value += "=== Regarding edits made during [[{{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}}]] [[{{subst:CURRENTYEAR}}]] ([[UTC]]) ===" + "\n" + "{{subst:" + "uw-bv" + "|" + varticle + "|subst=subst:}} " + IPnote + "~" + "~" + "~" + "~";
f.wpSummary.value = "Adding notice: {{uw-bv}}";
}
// Quick warning tabs
$(add_testn_tabs);
function add_testn_tabs()
{
var c1 = document.getElementById('column-one');
var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
if (document.title.indexOf("Editing User talk:") != -1)
{
tabs.appendChild(tnaddlilink('javascript:testn(1)',"t1"));
tabs.appendChild(tnaddlilink('javascript:testn(2)',"t2"));
tabs.appendChild(tnaddlilink('javascript:testn(3)',"t3"));
tabs.appendChild(tnaddlilink('javascript:vandn(1)',"v1"));
tabs.appendChild(tnaddlilink('javascript:vandn(2)',"v2"));
tabs.appendChild(tnaddlilink('javascript:vandn(3)',"v3"));
tabs.appendChild(tnaddlilink('javascript:vandn(4)',"w"));
tabs.appendChild(tnaddlilink('javascript:vandim()',"im"));
tabs.appendChild(tnaddlilink('javascript:warningn()',"bv"));
if(document.getElementById('ca-nstab-user'))
{
document.getElementById('ca-nstab-user').firstChild.innerHTML = 'User';
}
if(document.getElementById('ca-talk'))
{
document.getElementById('ca-talk').firstChild.innerHTML = 'Talk';
}
if(document.getElementById('ca-edit'))
{
document.getElementById('ca-edit').firstChild.innerHTML = 'Edit';
}
if(document.getElementById('ca-addsection'))
{
document.getElementById('ca-addsection').firstChild.innerHTML = '[+]';
}
if(document.getElementById('ca-history'))
{
document.getElementById('ca-history').firstChild.innerHTML = '[h]';
}
if(document.getElementById('ca-move'))
{
document.getElementById('ca-move').firstChild.innerHTML = '[m]';
}
if(document.getElementById('ca-delete'))
{
document.getElementById('ca-delete').firstChild.innerHTML = '[d]';
}
if(document.getElementById('ca-watch'))
{
document.getElementById('ca-watch').firstChild.innerHTML = '[w]';
}
if(document.getElementById('ca-unwatch'))
{
document.getElementById('ca-unwatch').firstChild.innerHTML = '[uw]';
}
if(document.getElementById('ca-protect'))
{
document.getElementById('ca-protect').firstChild.innerHTML = '[p]';
}
if(document.getElementById('ca-unprotect'))
{
document.getElementById('ca-unprotect').firstChild.innerHTML = '[up]';
}
}
}
// </nowiki></pre>