User:Lightdarkness/csd.js

// //This page is just testing, going to try to automate the adding of warning messages. var globalwarn; var pageName; myArray = document.title.split(/ - /); var page = myArray[0]; myregexp = new RegExp(" "); pageName = page.replace(myregexp, "_"); var globalCSD;

function CSDPage(CSD){ globalCSD = CSD; document.getElementById('bodyContent').innerHTML = 'Please wait' + '... ';     gml_xmlhttp = HTTPClient; if (!gml_xmlhttp) return; document.title = 'Grabbing ' + pageName + ' - Wikipedia, the free encyclopedia'; document.getElementById('csd').innerHTML += ' Grabbing page...'; gml_xmlhttp.open('GET', 'http://en.wikipedia.org/w/index.php?title=' + pageName + '&action=edit', true); gml_xmlhttp.onreadystatechange = CSDMore; gml_xmlhttp.send(null); }

function CSDMore { if (gml_xmlhttp.readyState != 4){ document.getElementById('csd').innerHTML += '.'; return } var form, newform, l;  // Insert the downloaded form in our current page, using // only hidden form inputs. doc = gml_XMLParse(gml_xmlhttp.responseText); form = doc.getElementById('editform');

var x; var t = form.wpTextbox1.value; myArray = t.split(/\n/); var add; add = true; var nocontent = "{" + "{" + "no" + "content" + "}" + "}"; var dbbio = "{" + "{" + "db-" + "bio" + "}" + "}"; var nnbio = "{" + "{" + "nn-" + "bio" + "}" + "}"; var dbnonsense = "{" + "{" + "db-" + "nonsense" + "}" + "}"; var nonsense = "{" + "{" + "nonsense" + "}" + "}"; var dbattack = "{" + "{" + "db-" + "attack" + "}" + "}"; var dbrepost = "{" + "{" + "db-" + "repost" + "}" + "}"; var dbempty = "{" + "{" + "db-" + "empty" + "}" + "}"; document.title = 'Searching for tags in ' + pageName + ' - Wikipedia, the free encyclopedia'; document.getElementById('csd').innerHTML += ' Searching for exsisting tags...'; for (x in myArray) {   if(myArray[x] == nocontent){ add = false; }   if(myArray[x] == dbbio){ add = false; }   if(myArray[x] == dbnonsense){ add = false; }   if(myArray[x] == nonsense){ add = false; }   if(myArray[x] == dbattack){ add = false; }   if(myArray[x] == dbrepost){ add = false; }   if(myArray[x] == nnbio){ add = false; }   if(myArray[x] == dbempty){ add = false; } }  if(add == true){ //alert('Yea, we can tag'); document.title = 'No tag found in ' + pageName + ' - Wikipedia, the free encyclopedia'; document.getElementById('csd').innerHTML += ' No tag found, adding...'; } else{ //alert('CSD tag found'); document.title = 'CSD TAG FOUND in ' + pageName + ' - Wikipedia, the free encyclopedia'; document.getElementById('csd').innerHTML += ' CSD tag FOUND! Will not add tag...'; return; } if (form.wpTextbox1.value.length == 1){ document.title = pageName + ' is blank. - Wikipedia, the free encyclopedia'; document.getElementById('csd').innerHTML += ' Article is blank, please be sure the article hasn\'t been deleted...'; return; } else{ document.title = pageName + ' length: ' + form.wpTextbox1.value.length + ' - Wikipedia, the free encyclopedia'; document.getElementById('csd').innerHTML += ' Article length: ' + form.wpTextbox1.value.length; } var curtext = form.wpTextbox1.value; form.wpTextbox1.value = ""; form.wpTextbox1.value += '\n'; form.wpTextbox1.value += '\n'; form.wpTextbox1.value += curtext; form.wpSummary.value = "db-" + globalCSD; newform = document.createElement('form'); l = form.getElementsByTagName('textarea'); for (i = l.length; i--; ) { var t = document.createElement('input'); t.type = 'hidden'; t.name = l[i].name; t.value = l[i].value; newform.appendChild(t); } l = form.getElementsByTagName('input'); for (i = l.length; i--; ) { if (l[i].name == 'wpSummary') { l[i].value = 'Tagging CSD: ' + globalCSD + ' using ATCSD'; } else if (l[i].name == 'wpMinoredit') { l[i].value = '1'; } else if (l[i].name == 'wpWatchthis') { if (!l[i].checked) continue; l[i].value = "on"; } else if (l[i].name == 'wpPreview') { continue; } else if (l[i].name == 'wpDiff') { continue; }   l[i].type = 'hidden'; newform.appendChild(l[i]); } newform.name = form.name; newform.method = form.method; newform.id = form.id; newform.action = form.action; document.title = 'Submitting form for ' + pageName + ' - Wikipedia, the free encyclopedia'; document.getElementById('csd').innerHTML += ' Submitting form...'; document.getElementById('csd').appendChild(newform); // Submit the form newform.submit; } //