Saucsse / Respawn MP Delete

// ==UserScript==
// @name         Respawn MP Delete
// @version      1.0
// @description  Craftbukkit
// @author       Craftbukkit
// @require      http://code.jquery.com/jquery-2.2.0.min.js
// @match        http://www.jeuxvideo.com/messages-prives/boite-reception.php*
// @grant        none
// ==/UserScript==
var page;
var nbMessage;
var nMessage;

function videMp(nPage, nbPage, data)
{
    var lengthMp = data.split('name="conv_select[]" value="').length-1;
    var fssession = data.split('<input type="hidden" name="fs_session" value="')[1].split('"')[0];
	var fstimestamp = data.split('<input type="hidden" name="fs_timestamp" value="')[1].split('"')[0];
	var fsversion = data.split('<input type="hidden" name="fs_version" value="')[1].split('"')[0];
	var fs_1 = data.split('<input type="hidden" name="fs_')[4].split('"')[0];
	var fs_12 = data.split('<input type="hidden" name="fs_'+fs_1+'" value="')[1].split('"')[0];
	var fs_2 = data.split('<input type="hidden" name="fs_')[5].split('"')[0];
	var fs_22 = data.split('<input type="hidden" name="fs_'+fs_2+'" value="')[1].split('"')[0];
    var tmpEnvoie = "";
    for (var i = 0; i < lengthMp; i++) {
        var tmpIdMessage = data.split('name="conv_select[]" value="')[i+1].split('"')[0];
        nMessage++;
        tmpEnvoie += "&conv_select[]="+tmpIdMessage;
    }
    $.post(page, "fs_session="+fssession+"&fs_timestamp="+fstimestamp+"&fs_version="+fsversion+"&fs_"+fs_1+"="+fs_12+"&fs_"+fs_2+"="+fs_22+"&conv_move=1337"+tmpEnvoie,  function(data){ document.getElementsByClassName("list-msg")[0].innerHTML = "<span id='papage'>Vidage MP "+nMessage+" / "+nbMessage+"</span>"; });
    nPage++;
    if(nPage <= nbPage)
        $.get("http://www.jeuxvideo.com/messages-prives/boite-reception.php?p="+nPage, function(data,succes){videMp(nPage, nbPage, data); });
}

function vider()
{
    nbMessage = document.getElementsByClassName("nb-pages")[0].innerHTML.split(" sur ")[1].split("<")[0];
    var nbPage = Math.ceil(nbMessage/25);
    nMessage = 0;
    var nPage = 1;
	document.getElementsByClassName("list-msg")[0].innerHTML = "<span id='papage'>Vidage MP 0 / "+nbMessage+"</span>";
	$.get("http://www.jeuxvideo.com/messages-prives/boite-reception.php?p="+nPage, function(data,succes){videMp(nPage, nbPage, data); });
}


if(document.body.innerHTML.indexOf('<div class="alert-row"> Aucune conversation à afficher') == "-1")
{
    page = window.location.href;
    document.getElementsByClassName("action-right")[0].innerHTML += '<button class="btn icon-bin" title="Tout supprimer" id="viderAll">Vider</button>';
    document.getElementById("viderAll").onclick = function(){ vider(); return false; };
}