Saucsse / Respawn Search

// ==UserScript==
// @name         Respawn Search
// @version      1.2
// @description  Compatiblity with Responsive
// @author       Craftbukkit
// @require      http://code.jquery.com/jquery-2.2.0.min.js
// @match        http://www.jeuxvideo.com/forums/42-*
// @match        http://www.jeuxvideo.com/forums/1-*
// @grant        none
// ==/UserScript==
var _BaseClassName="JvCare";jsli={getElementsByClassName:function(b){if(!document.getElementsByClassName){var d=new Array();var a=document.getElementsByTagName("span");for(i=0;i<a.length;i++){var c=a[i].className.split(" ");for(j=0;j<c.length;j++){if(c[j]===b){d[d.length]=a[i]}}}return d}else{return document.getElementsByClassName(b)}},LocalIterations:0,SpansTransform:0,IterationsVides:0,IsRunning:false,IsDone:false,Transformation:function(){jsli.IsRunning=true;try{var a=this.getElementsByClassName(_BaseClassName);var t=a.length;var o="0A12B34C56D78E9F";var x="charset,name,rel,rev,target,accesskey,id,style,tabindex,title".split(",");var y="blur,click,dblclick,focus,mousedown,mousemove,mouseover,mouseup,keydown,keyppress,keyup".split(",");var m,b="";var u,q,f=null;var g,c,r,h,w=0;var s=t;while(s--){u=a[s];h=u.className.indexOf(" ");w=u.className.indexOf(" ",h+1);if(w===-1){w=u.className.length}b="";if(h>0){m=u.className.substr(h+1,w-h-1);for(r=0;r<m.length;r+=2){g=o.indexOf(m.charAt(r));c=o.indexOf(m.charAt(r+1));b+=String.fromCharCode((g*16)+c)}}q="xXx "+u.className.substr(w+1,u.className.length-w-1);f=document.createElement("a");f.href=b;r=x.length;while(r--){try{h=x[r];if(w=u.getAttribute(h)){f[h]=w}}catch(v){}}for(var s=0,l=u.attributes,k=l.length;s<k;s++){if(l[s].nodeName.substring(0,5)==="data-"){try{f.setAttribute(l[s].nodeName,l[s].nodeValue)}catch(v){}}}r=y.length;while(r--){try{h=y[r];if(w=u["on"+h]){if(f.addEventListener){f.addEventListener(h,w,false)}else{if(f.attachEvent){f.attachEvent("on"+h,w)}}}}catch(v){}}f.className=q;r=u.childNodes.length;while(r--){f.appendChild(u.childNodes[0])}u.parentNode.insertBefore(f,u);u.parentNode.removeChild(u)}}catch(v){}jsli.LocalIterations++;jsli.SpansTransform+=t;if((jsli.SpansTransform>0)&&((t==0)&&(document.body))){jsli.IterationsVides++}if(jsli.IterationsVides<5){setTimeout("jsli.Transformation()",200)}else{jsli.IsRunning=false;jsli.IsDone=true;if(jsli.callbackStoreScript){jsli.callbackStoreScript()}}}};jsli.Transformation();

document.getElementsByClassName("bloc-liste-num-page")[0].innerHTML += '&nbsp;<input type="text" style="width:75px" class="searchintopic">&nbsp;<select class="srch" style="height: 100%;"><option value="0">Pseudo</option><option value="1">Message</option></select>&nbsp;<input type="button" value="Ok" class="buttonsrch">';
var inc = 1;
var didiv = new Array();
function loadToPage(page, data,ps,mo)
{
	if(data.indexOf('"http://m.jeuxvideo.com/forums/'+window.location.href.split("forums/")[1].split("-")[0]+'-'+window.location.href.split("-")[1]+'-'+window.location.href.split("-")[2]+'-1-0-1-0') == "-1" || inc == 1){
	var data2 = data.split('<div class="bloc-header">');
	var data3 = data.split('<div class="bloc-contenu">');
	var tmpSearch = "";
	for(var k=1;k<data2.length;k++)
	{
		var pseudoTmp = data2[k].split('>')[1].split('<')[0].trim();
		var messageTmp = data3[k].replace(/<(?:.|\n)*?>/gm, '');
		var dataTmp = '<div class="bloc-message-forum "'+data.split('<div class="bloc-message-forum "')[k];
		if(k<data2.length)
			dataTmp = '<div class="bloc-message-forum "'+data.split('<div class="bloc-message-forum "')[k].split('<div class="bloc-pagi-default">')[0];
		if(ps != null)
		{
			if(pseudoTmp.toLowerCase().indexOf(ps.toLowerCase()) != "-1")
			{
				tmpSearch += dataTmp;
				
			}
		}
		else
		{
			if(messageTmp.toLowerCase().indexOf(mo.toLowerCase()) != "-1")
			{
				tmpSearch += dataTmp;
			}
		}		
	}

	document.getElementsByClassName("conteneur-messages-pagi")[0].innerHTML += tmpSearch;
	jsli.Transformation();
	inc++;
	document.getElementById('papage').innerHTML = "Page "+inc;
	page = page.split("-")[0]+"-"+page.split("-")[1]+"-"+page.split("-")[2]+"-"+inc+"-0-1-0-o.htm";
	if(data.indexOf('<div class="bloc-liste-num-page"><span class="page-active">1</span></div><div class="pagi-after"></div></div>') == "-1" && inc <= 5001) 
		$.get(page, function(data,succes){loadToPage(page, data, ps, mo); });
	}
}
function commence(page, ps, mo)
{
	document.getElementsByClassName("conteneur-messages-pagi")[0].innerHTML = "<span id='papage'>Page 1</span>";
	page = page.split("-")[0]+"-"+page.split("-")[1]+"-"+page.split("-")[2]+"-1-0-1-0-o.htm";
	$.get(page, function(data,succes){loadToPage(page, data, ps, mo); });
}

document.getElementsByClassName("buttonsrch")[0].onclick = function(){ var mo = (document.getElementsByClassName("srch")[0].value != "0") ? document.getElementsByClassName("searchintopic")[0].value : null; var ps = (document.getElementsByClassName("srch")[0].value=="0") ? document.getElementsByClassName("searchintopic")[0].value : null; commence(window.location.href, ps, mo); };