
"use strict";
(function() {
	if ( document.addEventListener ) {
		document.addEventListener("DOMContentLoaded", function() {
			dataAnalyze();
		});
	} else if ( document.attachEvent ) {
		document.attachEvent("onreadystatechange", function() {
			dataAnalyze();
		});
	}
}());

var dataAnalyze = function() {
	// console.log();
	// alert();
	var chceklh = encodeURIComponent(location.href);
	//chceklh = "aaa";
	if (/eronanpa-douga.jp%2F/.test(chceklh)== false) {
		return;
	}

	var category_element = "div";
	if (category_element) {

		var x = document.getElementsByTagName("div");
		var category_text = "";
		for(var i = 0; i < x.length; ++i){

			if (x[i].className == "kizi-body"){
				// alert(x[i].textContent);
				category_text += x[i].textContent;
			}
			if (x[i].id == "kizi-body"){
				category_text += x[i].textContent;
			}
		}
		category_text = category_text.replace(/\r?\n\s+\t+/g,"");

	} else {
		var x = document.getElementsByTagName("div.kizi-body");
		var category_text = "";
		for(var i = 0; i < x.length; ++i){
			category_text += x[i].textContent;
		}
		category_text = category_text.replace(/\r?\n\s+\t+/g,"");
	}

	if (category_text) {
		category_text = category_text.replace(/\s+/g, "");
		//category_text = category_text.replace(/[a-zA-Z\<\>=\(\)$\{\};&:'\"\[\]\+_#.`\/\\-\s]+/g, "");
		category_text = category_text.replace(/[\<\>=\(\)$\{\};&:'\"\[\]\+_#.`\/\\-\s]+/g, "");
		category_text = category_text.substr(0,1000);
	}


	// alert(category_text);

	var allhtml = "";
	allhtml = document.getElementsByTagName('body')[0].innerHTML;
	allhtml = allhtml.replace(/\r?\n/g,"!NEWLINE!");

    var obj = new XMLHttpRequest();
    obj.open("POST", "https://unddeliv.com/parts/pc/post/parts.php", true);
    obj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

	obj.send("bg=F7F7F7&lc=EAEAEA&fc=000000&mf=FFFFFF&mb=E92300&bf=FFFFFF&bb=E92300&fs=14&dc=6&cc=3&pw=510&ai=cyclevideo-077&pt=" + encodeURIComponent(document.title) + "&ct=" + category_text + "&mn=%E3%83%8A%E3%83%B3%E3%83%91&lh=" + encodeURIComponent(location.href) + "&ah=" + encodeURIComponent(allhtml));

    obj.onreadystatechange = function() {
        if (obj.readyState == 4) {
            var res = obj.responseText;
            //alert(res);
            var elem = document.getElementById("undrep_block");
            elem.innerHTML = res;
        }
    }
};
