User:Parent5446/MediaWiki/AvatarMessaging.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:Parent5446/MediaWiki/AvatarMessaging. |
// <pre><nowiki>
// License: [[Public Domain]]
// Created by [[User:Parent5446]]
//Customizable Variables
var ProjectName="Avatar: The Last Airbender task force";
var MainProjectPage="Wikipedia:WikiProject%20Television/Avatar:%20The%20Last%20Airbender%20task%20force";
var IsMemberPageSubpageOfMainPage=true;
var MembersPage="members"; //If above value is set to true, only enter sub-page name (no slash or anything)
var IsTaskForce=true;
var ParentProject="Television WikiProject";
var ParentProjectMainPage="Wikipedia:WikiProject%20Television";
var EditSummary="";
var SectionHeading=""; //This will be added before the message name.
//DO NOT EDIT BELOW THIS LINE
//Global Variable
var UserArray;
var token;
var timestamp;
function getMemberArray() {
var xmlHttpMember;
try {
xmlHttpMember=new XMLHttpRequest();
}
catch (e) {
try {
xmlHttpMember=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
xmlHttpMember=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttpMember.onreadystatechange=function() {
if(xmlHttpMember.readyState==4&&xmlHttpMember.status==200) {
var MembersXML=xmlHttpMember.responseXML.documentElement;
for (i=0;i<MembersXML.getElementsByTagName('pl').length;i++) {
UserArray[x]=MembersXML.getElementsByTagName('pl')[i].attributes.title.nodeValue;
}
}
}
var url="http://en.wikipedia.org/w/api.php?action=query&plnamespace=3&prop=links&tlnamespace=3&format=xml&titles=";
if(IsMemberPageSubpageOfMainPage) {
url+=escape(MainProjectPage)+"/"+escape(MembersPage);
}
else {
url+=escape(MembersPage);
}
xmlHttpMember.open("GET",url,true);
xmlHttpMember.send(null);
}
function createEntryBox() {
if(wgPageName!="User:Parent5446/MediaWiki/AvatarMessaging.js") { return; }
var bodyContent='Message Header:<br /><input type="text" maxlength="50" name="MessageHeader" id="MessageHeader" size="25" title="Message Header" />';
bodyContent+='<br /><br />Message:<br /><textarea rows="26" cols="60" name="Message" id="Message" title="Message" /></textarea>';
bodyContent+='<br /><input type="button" name="Submit" id="Submit" value="Submit" onclick="submitMessage()" />';
document.getElementById('content').innerHTML=bodyContent;
}
function submitMessage() {
getMemberArray();
getToken();
for(x in UserArray) {
var xmlHttpMember;
try {
xmlHttpMember=new XMLHttpRequest();
}
catch (e) {
try {
xmlHttpMember=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
xmlHttpMember=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
alert("Your browser does not support AJAX!");
return false;
}
}
}
var MessageToSend='=='+escape(document.getElementById('MessageHeader').value)+'==\n'+escape(document.getElementById('Message').value);
var url='http://en.wikipedia.org/w/api.php?action=edit§ion=new¬minor=yes&recreate=yes&title='+escape(UserArray[x]);
url+='&text='+MessageToSend+'&token='+token;
xmlHttpMember.open("GET",url,true);
xmlHttpMember.send(null);
}
document.getElementById('content').innerHTML="Messages sent.";
}
function getToken() {
var xmlHttpMember;
try {
xmlHttpMember=new XMLHttpRequest();
}
catch (e) {
try {
xmlHttpMember=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
xmlHttpMember=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttpMember.onreadystatechange=function() {
if(xmlHttpMember.readyState==4&&xmlHttpMember.status==200) {
var TokenXML=xmlHttpMember.responseXML.documentElement;
var RawToken=TokenXML.getElementsByTagName('page')[0].attributes.edittoken.nodeValue;
token=escape(RawToken);
}
}
var url="http://en.wikipedia.org/w/api.php?action=query&prop=info&intoken=edit&format=xml&titles=";
if(IsMemberPageSubpageOfMainPage) {
url+=escape(MainProjectPage)+"/"+escape(MembersPage);
}
else {
url+=escape(MembersPage);
}
xmlHttpMember.open("GET",url,true);
xmlHttpMember.send(null);
}
addOnloadHook(createEntryBox());
//</pre></nowiki>