User:TigerShark/monobook.js

//Interiot's javascript edit counter if (document.title.indexOf('User:Interiot/Tool2/code.js') != -1) { mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js&action=raw&ctype=text/javascript'); }

//- //Server-based Wikibreak enforcer //-

// XMLHttpRequest support (thanks to Sam Hocevar for this code) // --

//var currentX = new Date; //alert(currentX);

if (document.implementation.createDocument) { var gml_xmlparser = new DOMParser; } function gml_XMLParse(string) { if (document.implementation.createDocument) { return gml_xmlparser.parseFromString(string, "text/xml"); } else if (window.ActiveXObject) { var gml_xmldoc = new ActiveXObject("Microsoft.XMLDOM"); gml_xmldoc.async = "false"; ret = gml_xmldoc.loadXML(string); if (!ret) return null; return gml_xmldoc.documentElement; } return null; }

var gml_xmlhttp;

function HTTPClient { var gml_http; if(window.XMLHttpRequest) { gml_http = new XMLHttpRequest; } else if (window.ActiveXObject) { try { gml_http = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { gml_http = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { gml_http = false; }   }  }  return gml_http; }

//Main Wikibreak logic (thanks to Mike1024 for the initial inspiration and code used as a template) //-

addOnloadHook(EnforceWikiBreak2);

function EnforceWikiBreak2 {     //Date based bypass for testing //var currentdate = new Date; //var enforced_break_end = new Date("November 1, 2006"); //alert(enforced_break_end); // if (currentdate < enforced_break_end) // {            //alert("Performing WikiBreak check..."); GetContents; // } }

function GetContents {

gml_xmlhttp = HTTPClient; if (!gml_xmlhttp) return;

history_url = "http://en.wikipedia.org/w/index.php?title=User:TigerShark/DateTime&action=purge";

gml_xmlhttp.open("GET", history_url, true); gml_xmlhttp.onreadystatechange = StepTwo; gml_xmlhttp.send(null);

}

function StepTwo { if (gml_xmlhttp.readyState != 4) return;

xml = gml_xmlhttp.responseText;

var iStart; var iEnd; strTest = "CHECKDATESTART"; iStart = xml.indexOf(strTest); strEnd = "CHECKDATEEND"; iEnd = xml.indexOf(strEnd);

if(iStart == -1) {   alert("CHECKDATESTART Not Found"); } else {    var thechar = ""; var icounter; for (icounter=iStart + 14; icounter<=iEnd-1; icounter=icounter+1) {       thechar += xml.charAt(icounter); }    //alert(thechar); var cDate = new Date(thechar);

//SET THIS TO THE END DATE/TIME FOR THE WIKIBREAK var enforceddate = new Date("October 26, 2008 10:00");

if (enforceddate > cDate) {      alert("You should be on a Wikibreak!!!"); window.location = "http://en.wikipedia.org/w/index.php?title=Special:Userlogout&returnto=Main_page"; }

} }