BANH / Respawn Message Delete

// ==UserScript==
// @name         Respawn Message Delete
// @version      1.1
// @description  You can know choose the date
// @author       Craftbukkit
// @require      http://code.jquery.com/jquery-2.2.0.min.js
// @match        http://www.jeuxvideo.com/profil/*?mode=historique_forum*
// @grant        none
// ==/UserScript==
var page;
var nMessageDelete;
var nMessageNonDelete;
var nMessage;
var dateArray = ["janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"];

function videMp(nPage, data)
{
    var ajaxHash = data.split('ajax_hash_moderation_forum" value="')[1].split('"')[0];
    var tmpEnvoie = "";
    var minDate = document.getElementById('mindate').value;
    var maxDate = document.getElementById('maxdate').value;
    minDate = new Date(minDate.split('/')[1]+"/"+minDate.split('/')[0]+"/"+minDate.split('/')[2]).getTime();
    maxDate = new Date(maxDate.split('/')[1]+"/"+maxDate.split('/')[0]+"/"+maxDate.split('/')[2]).getTime();

    for (var i = 0; i < data.split('<div class="bloc-header">').length-1; i++) {
        var tmpTmp = data.split('class="bloc-message-forum-anchor">')[i+1];
        if(tmpTmp.indexOf('msg-supprime') != "-1")
        {
            nMessageDelete++;
            document.getElementsByClassName("bloc-historique-forum")[0].innerHTML = "<span id='papage'><b>Vidage Message :</b><br /> Message supprimé : "+nMessage+" <br /> Message déjà supprimé : "+nMessageDelete+" <br /> Message non supprimé : "+nMessageNonDelete+" <br /> Page n°"+nPage+"</span>";
        }
        else
        {
            var tmpIdMessage = tmpTmp.split('"bloc-message-forum " data-id="')[1].split('"')[0];
            var tmpDate = tmpTmp.split('<div class="bloc-date-msg">')[1].split('target="_blank">')[1].split(' à')[0];
            var tmpMois = (dateArray.indexOf(tmpDate.split(' ')[1])+1 < 10) ? "0"+(dateArray.indexOf(tmpDate.split(' ')[1])+1) : (dateArray.indexOf(tmpDate.split(' ')[1])+1);
            var tmpJour = tmpDate.split(' ')[0];
            var tmpAn = tmpDate.split(' ')[2];
            var totalDate = new Date(tmpMois+"/"+tmpJour+"/"+tmpAn).getTime();
            if(totalDate >= minDate && totalDate <= maxDate)
            {
                nMessage++;
                tmpEnvoie = "&tab_message[]="+tmpIdMessage;
                $.get("http://www.jeuxvideo.com/forums/modal_del_message.php?type=delete&ajax_hash="+ajaxHash+""+tmpEnvoie,  function(data){ document.getElementsByClassName("bloc-historique-forum")[0].innerHTML = "<span id='papage'><b>Vidage Message :</b><br /> Message supprimé : "+nMessage+" <br /> Message déjà supprimé : "+nMessageDelete+" <br /> Message non supprimé : "+nMessageNonDelete+" <br /> Page n°"+nPage+"</span>"; });
            }
            else
            {
                nMessageNonDelete++;
            }
        }
    }
    if(data.indexOf(' pagi-suivant-actif">') != "-1")
    {
    var nextPage = "http:"+jvCake(data.split('<div class="pagi-after"><span><span class="JvCare ')[1].split(' ')[0]);
    nPage++;
    console.log(nextPage);
    if(data.indexOf(' pagi-suivant-actif">') != "-1")
        $.get(nextPage, function(data,succes){videMp(nPage, data); });
    }
}

//Cimer kiwec pour le jvCake
function jvCake(className) {
	var base16 = '0A12B34C56D78E9F';
	var s = className;

	var lien = '';
	for (var i = 0; i < s.length; i += 2) {
		lien += String.fromCharCode(base16.indexOf(s.charAt(i)) * 16 + base16.indexOf(s.charAt(i + 1)));
	}

	return lien;
}

function vider()
{
    nMessage = 0;
    nMessageDelete = 0;
    nMessageNonDelete = 0;
    var nPage = 1;
	document.getElementsByClassName("bloc-historique-forum")[0].innerHTML = "<span id='displayy' style='display:none'></span><span id='papage'><b>Vidage Message :</b><br /> Message supprimé : 0 <br /> Message déjà supprimé : 0 <br /> Message non supprimé : 0 <br /> Page n°1</span>";
	$.get(window.location.href, function(data,succes){videMp(nPage, data); });
}


page = window.location.href;
document.getElementsByClassName("titre-bloc")[0].innerHTML += '<br> -> Du : <input type="text" id="mindate" value="01/01/1970"> au <input type="text" id="maxdate" value="01/01/2100"> - <button class="btn icon-bin" title="Tout supprimer" id="viderAll">Vider</button>';
document.getElementById("viderAll").onclick = function(){ vider(); return false; };