User:Oxymoron83/twinklewarnauto.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:Oxymoron83/twinklewarnauto. |
importScript('User:AzaToth/twinklewarn.js');
addOnloadHook(twinklewarnauto);
//originally from [[User:DerHexer/rollback.js]]
function twinklewarnauto() {
if ( ( mw.config.get('wgNamespaceNumber') == 3 ) && ( QueryString.exists( 'vanarticle' )) ) {
if ( !isIPAddress (mw.config.get('wgTitle')) ) {
document.getElementById("siteSub").firstChild.nodeValue = "- - - No automatic warning - No IP - - -";
return;
}
document.editform.wpMinoredit.checked=true;
if (document.getElementById( 'wpTextbox1' ).value == "" ) {
if ( QueryString.get( 'vanarticle' ).slice(0, 5) == "User:" ) {
if ( QueryString.get( 'type' ) == "vand" ) {
spam("3", "Warning" , 23 , 0);
} else if ( QueryString.get( 'type' ) == "blank" ) {
spam("2", "Caution" , 22 , 0);
} else {
spam("1", "General note" , 21, 0);
}
} else {
spam("1", "General note" , 1, 0);
}
} else { //User talk not empty
var now = new Date();
var actual_time = now.getTime();
var splitted = document.forms["editform"].wpTextbox1.value.split("<!--");
var last_time = splitted[splitted.length-1].match(/([\:\d]+)\, (\d+) ([^\d]+) (\d+)/);
var last_timestamp = Date.parse(RegExp.$2 + " " + RegExp.$3 + " " + RegExp.$4 + " " + RegExp.$1 + ":00 GMT");
var difftime = actual_time - last_timestamp;
if (difftime < 69000) {
document.getElementById("siteSub").firstChild.nodeValue = " - - - No automatic warning - Received a warning in the last minute - - -";
return;
}
if ((difftime > 691200000) || (!last_time)) { //86400000 = 24h, 691200000 = 8d
if ( (QueryString.get( 'vanarticle' ).slice(0, 5) == "User:") && (QueryString.get( 'type' ) == "vand") ) {
spam("3", "Warning" , 23 , 0);
} else {
spam("2", "Caution" , 2 , difftime);
}
} else { // < 8d
if ( (splitted[splitted.length-1].search(/uw\-[^\d]*(\d)/) != -1) || (splitted[splitted.length-1].search(/Template\:Test/) != -1) || (splitted[splitted.length-1].search(/Template\:Blatantvandal/) != -1) || (splitted[splitted.length-1].search(/Uw\-bv/) != -1) ) {
var matchedtemplate = splitted[splitted.length-1].match(/uw\-[^\d]*(\d)/);
var matchednumber = RegExp.$1;
var matchedtemplate2 = splitted[splitted.length-1].match(/Template\:Test(\d)/);
var matchednumber2 = RegExp.$1;
if ( (splitted[splitted.length-1].search(/Template\:Blatantvandal/) != -1) || (splitted[splitted.length-1].search(/Uw\-bv/) != -1) ) {
matchednumber = 4;
}
if (matchednumber < matchednumber2) { matchednumber = matchednumber2; }
if (difftime > 111600000) { //111600000 = 31 h, 31h < x < 8d
if ( (matchednumber == 4) && ( QueryString.get( 'type' ) == "norm" ) ) { matchednumber = 3; }
if ( (matchednumber == 2) && ( QueryString.get( 'type' ) == "vand" ) ) { matchednumber = 3; }
if (matchednumber == 4) {
spam("4im", "Only warning" , 14 , difftime);
} else if (matchednumber == 3) {
spam("3", "Warning" , 13 , difftime);
} else {
spam("2", "Caution" , 12 , difftime);
}
} else { // < 31 h
if (matchednumber == 4) {
if ( difftime > 36000000 ) { //36000000 = 10 h, 10h < x < 31h
spam("4im", "Only warning" , 5 , difftime);
} else { // final warning and < 10h ago
//reports in test status only
if ((mw.config.get('wgUserName') != "Oxymoron83") && (mw.config.get('wgUserName') != "Jauerback") && (mw.config.get('wgUserName') != "KnowledgeOfSelf") && (mw.config.get('wgUserName') != "Jan eissfeldt")) {
document.getElementById("siteSub").firstChild.nodeValue = "- - - No automatic warning - Reached level 4 - - -";
return;
} else {
if (userIsInGroup( 'sysop' ) ) {
var alerttext = "Vandalism after final warning on " + ( QueryString.exists( 'vanarticle' ) ? QueryString.get( 'vanarticle' ) : '[unknown]');
if ( (mw.config.get('wgTitle') == "82.148.96.68") || (mw.config.get('wgTitle') == "82.148.97.69") || (mw.config.get('wgTitle') == "145.97.39.143") ) { alerttext = "*** SENSITIVE IP ——— " + alerttext + " ***"; }
location.href = mw.config.get('wgServer') + "/wiki/Special:Contributions/" + mw.config.get('wgTitle');
window.alert( alerttext );
return;
} else {
var meldenquery = {
'title': 'Wikipedia:Administrator intervention against vandalism',
'action': 'edit',
'section':'1',
'vanarticle': QueryString.exists( 'vanarticle' ) ? QueryString.get( 'vanarticle' ) : '',
'vandal': mw.config.get('wgTitle'),
'vanarticlerevid': QueryString.exists( 'vanarticlerevid' ) ? QueryString.get( 'vanarticlerevid' ) : '',
'vanarticlegoodrevid': QueryString.exists( 'vanarticlegoodrevid' ) ? QueryString.get( 'vanarticlegoodrevid' ) : '',
//'type': type,
//'count': QueryString.exists( 'count' ) ? QueryString.get( 'count' ) : '',
'aivhelper': true
};
window.open(mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( meldenquery ),'VM','');
}
}
}
} else if (matchednumber == 3) {
spam("4", "Final warning" , 4 , difftime);
} else {
spam("3", "Warning" , 3 , difftime);
}
}
} else { //last warning unknown
spam("2", "Caution", 9 , difftime);
}
}
}
}
}
function spam( Stufe, StufeSum, lognr, difftime2 ) {
document.getElementById("siteSub").firstChild.nodeValue = "Message-ID: " + lognr;
var text = document.getElementById( 'wpTextbox1' ).value;
var date = new Date();
var headerRe = new RegExp( "^==+\\s*" + date.getUTCMonthName() + "\\s+" + date.getUTCFullYear() + "\\s*==+", 'm' );
if( !headerRe.exec( text ) ) {
text += "\n== " + date.getUTCMonthName() + " " + date.getUTCFullYear() + " ==\n";
}
switch( QueryString.get( 'type' ) ) {
case 'vand':
Art = "Vandalism";
Tmpl = "uw-vandalism";
break;
case 'blank':
Art = "Removal of content";
Tmpl = "uw-delete";
break;
case 'source':
Art = "Addition of unsourced material";
Tmpl = "uw-unsourced";
break;
case 'spam':
Art = "Adding spam links";
Tmpl = "uw-spam";
break;
default:
Art = "Editing tests";
Tmpl = "uw-test";
break;
}
document.getElementById( 'wpTextbox1' ).value = text + "\n\{\{subst:" + Tmpl + Stufe + "|"+ QueryString.get( 'vanarticle' ) + "|subst=subst:\}\} --\~\~\~\~\n";
document.getElementById( 'wpSummary' ).value = StufeSum + ": " + Art + " on [[" + QueryString.get( 'vanarticle' ) + "]]";
document.editform.wpSave.click();
}