User:Voice of All/Approvals.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:Voice of All/Approvals. |
//<pre><nowiki>
function add_bottabs()
{
if (document.title.indexOf('Editing Wikipedia:Bots/Requests for approval/') ==0)
{
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlimenu(tabs, 'bot approval', 'respfunc');
var respfunc = document.getElementById('respfunc').getElementsByTagName('ul')[0];
addlilink(respfunc, 'javascript:rfa_trial(1)',"trial (t)", '');
addlilink(respfunc, 'javascript:rfa_trial(2)',"trial (e)", '');
addlilink(respfunc, 'javascript:rfa_pass(1)',"app. (f)", '');
addlilink(respfunc, 'javascript:rfa_pass(0)',"app. (nf)", '');
addlilink(respfunc, 'javascript:rfa_pass(2)',"app. task", '');
addlilink(respfunc, 'javascript:rfa_fail()',"deny", '');
addlilink(respfunc, 'javascript:rfa_arch()',"done", '');
}
else if (document.title.indexOf('Editing Wikipedia:Bots/Requests for approval') ==0)
{
if (location.href.search(/&jstext=/) !=-1)
{
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlimenu(tabs, 'bot approval', 'respfunc');
var respfunc = document.getElementById('respfunc').getElementsByTagName('ul')[0];
addlilink(respfunc, 'javascript:add_text()',"Add", '');
alert('Add "<JSADD>" to the correct place and press the "add" tab');
}
}
}
function add_text()
{
var target = unescape(location.href.split('&jstext=')[1].split('&')[0]);
var f = document.editform, t = f.wpTextbox1;
if (t.value.search(/<JSADD>/) ==-1) return;
t.value = t.value.replace(/<JSADD>/g,target);
f.wpSummary.value += "JS: adding " + target;
}
//
var approvals_url = 'Wikipedia:Bots/Requests_for_approval';
var approved_list_url = 'Wikipedia:Bots/Approved_bot_requests';
var rejected_list_url = 'Wikipedia:Bots/Requests_for_approval/rejected';
function rfa_trial(type)
{
var name = document.title.split('/Requests for approval/')[1].split(' (section)')[0];
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
if (type==1)
t.value +=":[[Image:Symbol support vote.svg|20px]] Bot trial run approved for the duration of one week. " + "~" + "~" + "~" + "~";
else
t.value +=":[[Image:Symbol support vote.svg|20px]] Bot trial run approved for 50 edits. " + "~" + "~" + "~" + "~";
target = "*<!--TRIAL" + name + "-->{{botlinks|" + name + "}} ''Approved for trials as of ~~~~~''";
f.wpSummary.value += "Response: trial run approved";
window.open(mw.config.get('wgServer') + '/w/index.php?title=' + approvals_url + '&action=edit§ion=3&jstext=' + escape(target),'RFBA:add',
'location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');
}
function rfa_fail()
{
var name = document.title.split('/Requests for approval/')[1].split(' (section)')[0];
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value +=":[[Image:Symbol oppose vote.svg|20px]] '''Bot not approved''', discussion archived. " + "~" + "~" + "~" + "~";
if (t.value.search(/:''The above discussion is preserved as an archive/) !=-1)
{t.value = '<noinclude>' + '\n' + t.value + '\n' + '</noinclude>'; alert('Please tag manually.');}
else
{t.value = '<noinclude>{{subst:debate top}}' + '\n' + t.value + '\n' + '{{subst:debate bottom}}</noinclude>';}
f.wpSummary.value += "Archiving, bot not approved";
window.open(mw.config.get('wgServer') + '/w/index.php?title=' + rejected_list_url + '&action=edit','RFBA:archf',
'location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');
}
function rfa_pass(flag)
{
var name = document.title.split('/Requests for approval/')[1].split(' (section)')[0];
var f = document.editform, t = f.wpTextbox1;
target ='';
if (t.value.length > 0)
t.value += '\n';
if (flag==1)
{
t.value +=":[[Image:Symbol keep vote.svg|20px]] '''Approved'''; the bot shall run ''with'' a flag. " + "~" + "~" + "~" + "~";
f.wpSummary.value += "Response: bot approved (flagged)";
target = "{{botlinks|" + name + "}} ''Approved on ~~~~~'' '''(flag needed)'''";
}
else if (flag==0)
{
t.value +=":[[Image:Symbol keep vote.svg|20px]] '''Approved'''; the bot shall run ''without'' a flag. " + "~" + "~" + "~" + "~";
f.wpSummary.value += "Response: bot approved (not flagged)";
target = "{{botlinks|" + name + "}} ''Approved on ~~~~~'' ''(not flagged)''";
}
else if (flag==2)
{
t.value +=":[[Image:Symbol keep vote.svg|20px]] '''Task approved'''. " + "~" + "~" + "~" + "~";
f.wpSummary.value += "Response: task approved";
target = "{{botlinks|" + name + "}} ''Task approved on ~~~~~''";
}
//approved reqs
window.open(mw.config.get('wgServer') + '/w/index.php?title=' + approved_list_url + '&action=edit§ion=4&jstext=' + escape(target),'RFBA:add',
'location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');
//bots in a trial, bot should be removed from here if listed
window.open(mw.config.get('wgServer') + '/w/index.php?title=' + approvals_url + '&action=edit§ion=3','RFBA:rm',
'location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');
}
function rfa_arch()
{
var f = document.editform, t = f.wpTextbox1;
if (t.value.search(/:''The above discussion is preserved as an archive/) !=-1)
{t.value = '<noinclude>' + '\n' + t.value + '\n' + '</noinclude>'; alert('Please tag manually.');}
else
{t.value = '<noinclude>{{subst:debate top}}' + '\n' + t.value + '\n' + '{{subst:debate bottom}}</noinclude>';}
window.open(approvals_url,'RFBA:remove',
'location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');
document.editform.wpMinoredit.checked = true;
f.wpSummary.value += "Archiving request";
var URL ='http://en.wikipedia.org/w/index.php?title=Wikipedia:Bots/Requests_for_approval/Approved&action=edit';
window.open(URL,'RFBA:archp',
'location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');
}
$(approvals_main)
function approvals_main()
{
add_bottabs();
}
//</nowiki></pre>