User:Essjay/checkuser.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.
// NOTE: I've changed several things in this script, and had to make the same // // changes a number of times. Future changes should be merged in, rather than // // blanket copy-pasted, please. // //<pre><nowiki> function jssubmitclose() { var form = document.getElementById('editform'); form.submit(); } //END //Auto-replace function oldautoreplacetxt(what,withw) { i = 1; var original = document.editform.wpTextbox1.value; if (what == ''){alert("Invalid command."); return;} else if (what == 'null'){alert("Action cancelled."); return;} else { if (withw == ''){alert("All such appearances of text will be removed.");} else if (withw.split(what)[1] != undefined) {alert("Action cancelled to avoid infinite loop."); return;} else { if (document.editform.wpTextbox1.value.split(what)[1] != undefined) { while (i == 1) { document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(what, withw); if (document.editform.wpTextbox1.value.indexOf(what) != -1) {i = 1;} else {i = -1;} } } //document.editform.wpSummary.value += 'JS: Replacing text "' + what + '" with "' + withw + '" '; } } } //END function markminor() { var form = document.getElementById('bodyContent'); l = form.getElementsByTagName('input'); for (i = 0; i < l.length; i++) { if (l[i].name == 'wpMinoredit') {l[i].value = '1'; l[i].checked=true;} } } function jssubmit() { var form = document.getElementById('bodyContent'); l = form.getElementsByTagName('input'); for (i = 0; i < l.length; i++) { if (l[i].name == 'wpMinoredit') {l[i].value = '1'; l[i].checked=true;} } var form = document.getElementById('editform'); form.submit(); } addOnloadHook(CaseADD) function CaseADD() { if (location.href.indexOf('&fakeaction=CaseADD&target=') != -1) { addTab("javascript:Alpha_userwait()", "(Add)", "ca-add", "Add", ""); alert('Add "NEW" to the proper alphabetical location and press (add).' + '\n' + 'The necessary spaces above and below will be added automatically.'); var name = unescape(location.href.split('&target=')[1].split('&badlist=')[0]); document.editform.wpSummary.value += "Adding [[User:" + name + "]] case."; if (document.editform.wpTextbox1.value.indexOf('*[[Wikipedia:Requests for checkuser/Case/' + name) != -1) {alert('A case for this user already exists, be sure to integrate them after pressing "(add)".');} } } // var Alpha_user_done = 0; function Alpha_userwait() { if (Alpha_user_done == 1){alert('Already added.'); return;} if (document.editform.wpTextbox1.value.indexOf('NEW') != -1){Alpha_user_done=1;} var name = unescape(location.href.split('&target=')[1].split('&badlist=')[0]); var thebadlist = unescape(location.href.split('&badlist=')[1]); if (document.editform.wpTextbox1.value.indexOf('*[[Wikipedia:Requests for checkuser/Case/' + name) != -1) { var case_count_txt = document.editform.wpTextbox1.value.split('*[[Wikipedia:Requests for checkuser/Case/' + name)[1]; case_count_txt = case_count_txt.split('*[[Wikipedia:')[0]; if (case_count_txt.indexOf('*Second:') == -1) { var to_add = "**Second: " + thebadlist + "\n"; } else if (case_count_txt.indexOf('*Second:') != -1) { var to_add = "**Third: " + thebadlist + "\n"; } else if (case_count_txt.indexOf('*Third:') != -1) { var to_add = "**Fourth: " + thebadlist + "\n"; } else if (case_count_txt.indexOf('*Fourth:') != -1) { var to_add = "**Fifth: " + thebadlist + "\n"; } else if (case_count_txt.indexOf('*Fifth:') != -1) { var to_add = "**Sixth: " + thebadlist + "\n"; } else if (case_count_txt.indexOf('*Sixth:') != -1) { var to_add = "**Seventh: " + thebadlist + "\n"; } else if (case_count_txt.indexOf('*Seventh:') != -1) { var to_add = "**Eight: " + thebadlist + "\n"; } else if (case_count_txt.indexOf('*Eight:') != -1) { var to_add = "**Ninth: " + thebadlist + "\n"; } else if (case_count_txt.indexOf('*Ninth:') != -1) { var to_add = "**Tenth: " + thebadlist + "\n"; } else { var to_add = "**Next: " + thebadlist + "\n"; } } else {var to_add = "\n" + "*[[Wikipedia:Requests for checkuser/Case/" + name + "|'''" + name + "''']]: " + thebadlist + "\n";} document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace('NEW',to_add); markminor(); } addOnloadHook(CUmovedown) function CUmovedown() { if (location.href.indexOf('&fakeaction=RFCUmoveC&target=') != -1) { var pagename = unescape(location.href.split('&target=')[1]); var pagefind = "{{" + pagename + "}}"; var txt = document.editform.wpTextbox1.value; if (txt.indexOf(pagefind) == -1) {alert('Case "' + pagename + '" not found.'); return;} if (txt.indexOf('==Completed requests==') == -1) {alert('Page format error.'); return;} if (txt.split('==Completed requests==')[1].indexOf(pagename) != -1){alert('Case already moved.'); return;} if (txt.split('==Completed requests==')[1].split('<!-- subpages begin below this mark -->')[1] == undefined) {alert('Page format error.'); return;} var prereq = txt.split('==Completed requests==')[0]; var oldreq = txt.split('==Completed requests==')[1].split('<!-- subpages begin below this mark -->')[1]; oldreq = '==Completed requests==' + '\n' + '<!--put completed requests at the top of the list-->' + '\n' + '\n' + '<!-- subpages begin below this mark -->' + '\n' + pagefind + '\n' + oldreq; document.editform.wpTextbox1.value = prereq.replace('\n' + pagefind,'').replace(pagefind,'') + oldreq; document.editform.wpSummary.value = "Moving [[User:" + pagename.split('/Case/')[1] + "|" + pagename.split('/Case/')[1] + "]] case to completed."; alert('Case "' + pagename + '" found and moved to fulfilled section.'); markminor(); oldautoreplacetxt('----\n----','----'); //jssubmit(); } else if (location.href.indexOf('&fakeaction=RFCUmoveD&target=') != -1) { var pagename = unescape(location.href.split('&target=')[1]); var pagefind = "{{" + pagename + "}}"; var txt = document.editform.wpTextbox1.value; if (txt.indexOf(pagefind) == -1) {alert('Case "' + pagename + '" not found.'); return;} if (txt.indexOf('==Declined requests==') == -1) {alert('Page format error.'); return;} if (txt.split('==Declined requests==')[1].indexOf(pagename) != -1){alert('Case already moved.'); return;} if (txt.split('==Declined requests==')[1].split('<!-- subpages begin below this mark -->')[1] == undefined) {alert('Page format error.'); return;} var prereq = txt.split('==Declined requests==')[0]; var oldreq = txt.split('==Declined requests==')[1].split('<!-- subpages begin below this mark -->')[1]; oldreq = '==Declined requests==' + '\n' + '<!--put declined requests at the top of the list-->' + '\n' + '\n' + '<!-- subpages begin below this mark -->' + '\n' + pagefind + '\n' + oldreq; document.editform.wpTextbox1.value = prereq.replace('\n' + pagefind,'').replace(pagefind,'') + oldreq; document.editform.wpSummary.value = "Moving [[User:" + pagename.split('/Case/')[1] + "|" + pagename.split('/Case/')[1] + "]] case to completed."; alert('Case "' + pagename + '" found and moved to denied section.'); markminor(); oldautoreplacetxt('----\n----','----'); //jssubmit(); } else if (location.href.indexOf('&fakeaction=RFCUdel&target=') != -1) { var pagename = unescape(location.href.split('&target=')[1]); var pagefind = "{{" + pagename + "}}"; var txt = document.editform.wpTextbox1.value; if (txt.indexOf('==Declined requests==') == -1) {alert('Page format error.'); return;} if (txt.split('==Declined requests==')[1].indexOf(pagefind) == -1) {alert('Case "' + pagename + '" not found.'); return;} document.editform.wpTextbox1.value = txt.replace('\n' + pagefind,'').replace('\n' + pagefind,'').replace(pagefind,''); document.editform.wpSummary.value = "Archiving case for [[User:" + pagename.split('/Case/')[1] + "|" + pagename.split('/Case/')[1] + "]]."; alert('Case "' + pagename + '" found and removed from the fulfilled/denied section.'); markminor(); oldautoreplacetxt('----\n----','----'); //jssubmit(); } } addOnloadHook(CUlinks) function CUlinks() { if(document.title.indexOf("Wikipedia:Requests for checkuser/Case/") == 0) { var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; addlimenu(tabs, 'complete', 'carchfunc'); var carchfunc = document.getElementById('carchfunc').getElementsByTagName('ul')[0]; addlilink(carchfunc, 'javascript:CUdonearch(1)', 'done', ''); addlilink(carchfunc, 'javascript:CUdonearch(2)', 'rej.', ''); } if(document.title.indexOf("Editing Wikipedia:Requests for checkuser/Case/") == 0) { var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; addlimenu(tabs, 'CheckUser', 'cclosefunc'); var cclosefunc = document.getElementById('cclosefunc').getElementsByTagName('ul')[0]; //Checkuser functions addlilink(cclosefunc, 'javascript:CUdone(1)', 'confirm', ''); addlilink(cclosefunc, 'javascript:CUdone(2)', 'likely', ''); addlilink(cclosefunc, 'javascript:CUdone(3)', 'possible', ''); addlilink(cclosefunc, 'javascript:CUdone(4)', 'inconclusive', ''); addlilink(cclosefunc, 'javascript:CUdone(5)', 'unlikely', ''); addlilink(cclosefunc, 'javascript:CUdone(6)', 'unrelated', ''); addlilink(cclosefunc, 'javascript:CUdone(7)', 'decline', ''); addlilink(cclosefunc, 'javascript:CUdone(8)', 'more info', ''); addlilink(cclosefunc, 'javascript:CUdone(9)', 'note', ''); addlilink(cclosefunc, 'javascript:CUdone(10)', 'fishing', ''); addlilink(cclosefunc, 'javascript:CUdone(11)', 'clerk help', ''); addlilink(cclosefunc, 'javascript:CUdone(12)', 'clerk', ''); addlilink(cclosefunc, 'javascript:CUdone(13)', 'unnecessary', ''); addlilink(cclosefunc, 'javascript:CUdone(14)', 'rejected', ''); addlilink(cclosefunc, 'javascript:CUdone(15)', 'IPblocked', ''); if (document.title.indexOf("(section)") != -1) { //Checkuser functions addlimenu(tabs, 'complete', 'carchfunc'); var carchfunc = document.getElementById('carchfunc').getElementsByTagName('ul')[0]; addlilink(carchfunc, 'javascript:CUdonearch(1)', 'done', ''); addlilink(carchfunc, 'javascript:CUdonearch(2)', 'rej.', ''); addlilink(carchfunc, 'javascript:CUdonearch(3)', 'arch', ''); } } } function CUdonearch(num) { if (num != 3 && document.getElementById('bodyContent').innerHTML.search('The following discussion is preserved as an archive') != -1) if (num == 3 && document.editform.wpTextbox1.value.search('The following discussion is preserved as an archive') != -1) {alert('Case already closed'); return;} var username = document.title.replace('Editing ','').split(' (section)')[0].split(' - ')[0]; if (num==1) { window.open('http://en.wikipedia.org/w/index.php?title=Wikipedia:Requests_for_checkuser&action=edit&fakeaction=RFCUmoveC&target=' + escape(username), 'targetnameRFCUmov', 'location=no,toolbar=no,status=no,directories=no,scrollbars=yes'); } else if (num==2) { window.open('http://en.wikipedia.org/w/index.php?title=Wikipedia:Requests_for_checkuser&action=edit&fakeaction=RFCUmoveD&target=' + escape(username), 'targetnameRFCUmov', 'location=no,toolbar=no,status=no,directories=no,scrollbars=yes'); } else if (num==3) { var username = document.title.replace('Editing ','').split(' (section)')[0].split(' - ')[0]; var user_name = document.title.split(' (section)')[0].split(' - ')[0].split('/Case/')[1]; var offset=0; var badlist = ''; var badlist_show = ''; var txt = document.editform.wpTextbox1.value; if (txt.indexOf("{{subst:Rfcub}}") !=-1 || txt.indexOf("{{subst:Rfcua}}") !=-1) {alert('Case already closed!'); return;} oldautoreplacetxt('{{Checkuser|','{{checkuser|'); oldautoreplacetxt('{{Checkip|','{{checkip|'); oldautoreplacetxt('{{Vandal|','{{vandal|'); var l = txt.split('{{checkuser|'); for (var i=1; i< l.length; i++) { name = l[i].split('}}')[0]; if (name != user_name && badlist.indexOf(name) ==-1) { badlist_show += name + '\n'; badlist+=name; if (i != l.length-1) {badlist+='; ';} } } //fix extra ; mark if (txt.indexOf('{{checkuser|') == -1) {badlist = badlist.replace('; ','');} // if (txt.indexOf('{{vandal|') != -1) {badlist+='; ';} var l = txt.split('{{vandal|'); for (var i=1; i< l.length; i++) { name = l[i].split('}}')[0]; if (name != user_name && badlist.indexOf(name) ==-1) { badlist_show += name + '\n'; badlist+=name; if (i != l.length-1) {badlist+='; ';} } } //fix extra ; mark if (txt.indexOf('{{checkip|') != -1) {badlist+='; ';} // var l = txt.split('{{checkip|'); for (var i=1; i< l.length; i++) { name = l[i].split('}}')[0]; badlist_show += name + '\n'; badlist+=name; if (i != l.length-1) {badlist+='; ';} } alert('Possible user and IP socks:' + '\n' + badlist_show); if (txt.indexOf("<noinclude>") != -1) { var splitbefore = document.editform.wpTextbox1.value.split("<noinclude>")[0]; document.editform.wpTextbox1.value = "{{subst:Rfcua}}" + "\n" + splitbefore + "\n" + "{{subst:Rfcub}}" + "\n" + document.editform.wpTextbox1.value.split(splitbefore)[1]; } else { document.editform.wpTextbox1.value = "{{subst:Rfcua}}" + "\n" + document.editform.wpTextbox1.value + "\n" + "{{subst:Rfcub}}"; } document.editform.wpSummary.value = "Closing case."; window.open('http://en.wikipedia.org/w/index.php?title=Wikipedia:Requests_for_checkuser&action=edit&fakeaction=RFCUdel&target=' + escape(username),'targetnameRFCUdel','location=no,toolbar=no,status=no,directories=no,scrollbars=yes'); var name = username.split('/Case/')[1]; var letter = name.substring(0,1).toLowerCase(); var sec=0; var secoffset=1; if (letter == 'a'){sec=1;} else if (letter == 'b'){sec=2;} else if (letter == 'c'){sec=3;} else if (letter == 'd'){sec=4;} else if (letter == 'e'){sec=5;} else if (letter == 'f'){sec=6;} else if (letter == 'g'){sec=7;} else if (letter == 'h'){sec=8;} else if (letter == 'i'){sec=9;} else if (letter == 'j'){sec=10;} else if (letter == 'k'){sec=11;} else if (letter == 'l'){sec=12;} else if (letter == 'm'){sec=13;} else if (letter == 'n'){sec=14;} else if (letter == 'o'){sec=15;} else if (letter == 'p'){sec=16;} else if (letter == 'q'){sec=17;} else if (letter == 'r'){sec=18;} else if (letter == 's'){sec=19;} else if (letter == 't'){sec=20;} else if (letter == 'u'){sec=21;} else if (letter == 'v'){sec=22;} else if (letter == 'w'){sec=23;} else if (letter == 'x'){sec=24;} else if (letter == 'y'){sec=25;} else if (letter == 'z'){sec=26;} else {sec=0;} sec+=secoffset; window.open('http://en.wikipedia.org/w/index.php?title=Wikipedia:Requests_for_checkuser/Case&action=edit§ion=' + sec + '&fakeaction=CaseADD&target=' + escape(name) + '&badlist=' + escape(badlist), 'targetnameCaseADD', 'location=no,toolbar=no,status=no,directories=no,scrollbars=yes'); //jssubmit(); } } // CUdonealready = 0; // function CUdone(type) { var z = 0; document.editform.wpTextbox1.value.replace('<noinclude>{{Wikipedia:Requests for checkuser/Inputbox/Sample/Tag}}</noinclude>',''); if (type == 1) { CUdonealready=1; document.editform.wpSummary.value += "Confirmed."; var txt_add = "{{Confirmed}}. ~~~~"; } else if (type == 2) { CUdonealready=1; var txt_add = "{{Likely}}. ~~~~"; document.editform.wpSummary.value += "Likely."; } else if (type == 3) { CUdonealready=1; var txt_add = "{{Possible}}. ~~~~"; document.editform.wpSummary.value += "Possible."; } else if (type == 4) { CUdonealready=1; var txt_add = "{{Inconclusive}}. ~~~~"; document.editform.wpSummary.value += "Inconclusive."; } else if (type == 5) { CUdonealready=1; var txt_add = "{{Unlikely}}. ~~~~"; document.editform.wpSummary.value += "Unlikely."; } else if (type == 6) { CUdonealready=1; var txt_add = "{{Unrelated}}. ~~~~"; document.editform.wpSummary.value += "Unrelated."; } else if (type == 7) { CUdonealready=1; var txt_add = "{{Declined}}. ~~~~"; document.editform.wpSummary.value += "Declined."; } else if (type == 8) { CUdonealready=1; var txt_add = "{{MoreInfo}}. ~~~~"; document.editform.wpSummary.value += "More information required."; } else if (type == 9) { CUdonealready=1; var txt_add = "{{TakeNote}} ~~~~"; document.editform.wpSummary.value += "Note."; } else if (type == 10) { CUdonealready=1; var txt_add = "{{Fishing}} ~~~~"; document.editform.wpSummary.value += "No fishing."; } else if (type == 11) { CUdonealready=1; var txt_add = "{{clerk request}} ~~~~"; document.editform.wpSummary.value += "Clerk attention required."; } else if (type == 12) { CUdonealready=1; var txt_add = "{{clerknote}} ~~~~"; document.editform.wpSummary.value += "Clerk note."; } else if (type == 13) { CUdonealready=1; var txt_add = "{{unnecessary}} ~~~~"; document.editform.wpSummary.value += "Unnecessary."; } else if (type == 14) { CUdonealready=1; var txt_add = "{{Thrown out}} ~~~~"; document.editform.wpSummary.value += "Rejected."; } else if (type == 15) { CUdonealready=1; var txt_add = "{{IPblock}} ~~~~"; document.editform.wpSummary.value += "IP blocked."; } if (document.editform.wpTextbox1.value.indexOf('<noinclude>') == -1) {document.editform.wpTextbox1.value += "\n" + txt_add;} else { var before = document.editform.wpTextbox1.value.split('<noinclude>')[0]; var after = document.editform.wpTextbox1.value.split(before)[1]; document.editform.wpTextbox1.value = before + "\n" + txt_add + "\n" + after; } document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace('<!--Please do not remove the following tag until this case has been listed on RFCU. -->',''); document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace('<noinclude>{{Wikipedia:Requests for checkuser/Inputbox/Sample/Tag}}</noinclude>',''); document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(/\n\n\n/g,'\n\n'); } //</nowiki></pre>