gugasfrk / OGame - Chat Alliance Lmdb

// ==UserScript==
// @name           OGame - Chat Alliance Lmdb
// @author         Isamth - ogame.fr - uni102 (90%) snaquekiller (10%)
// @include        http://s118-pt.ogame.gameforge.com/game/index.php?page=*
// @include        http://lmdb.forumactif.com/*
// ==/UserScript==

// Version 1.1
      var url = location.href;
      var server = url.match(/[a-z0-9]{4,10}\.ogame\.[a-z]{2,4}/gi);
	  var chat = "";


// chatbox_top  85901
 
	  
	  var sbival = GM_getValue("sbival_"+server);
	  
	  
	if( typeof(sbival) == 'undefined')
	{
	sbival = "85901";
	GM_setValue("sbival_"+server, "85901");
	}
	    

	sbi = "https://www.chatbutton.com/chatroom/18350568/#"+sbival;

	
	
  	if( url.indexOf('http://lmdb.forumactif.com/forum.htm') >-1 ) 
	{
	 var element = document.getElementById('chatbox_top');  //Pour permuter l'image
     var p = document.createElement("div");

		if(screen.width >= 1600)
		{

		 chat =  '<iframe src='+sbi+' width="162" height="650" frameborder="0" allowtransparency="true"></iframe>';
		p.setAttribute('style', 'position:relative;display:block; left:0px; top:525px; width: 167px; height: 651px; allowtransparency="true";');
		}
		else
		{
		 chat = '<iframe src='+sbi+' width="125" height="650" frameborder="0" allowtransparency="true"></iframe>';
		p.setAttribute('style', 'position:relative;display:block; left:0px; top:525px; width: 131px; height: 651px; allowtransparency="true";');
		}


	p.innerHTML = chat;
	p.setAttribute('id', 'toto');
	element.appendChild(p);

	}




	  var pos = GM_getValue("pos_"+server);
	  var swi = GM_getValue("swi_"+server);

	  
		if( typeof(pos) == 'undefined')
	{
		pos = "on";
		GM_setValue("pos_"+server, "on");
	}

	
		if( typeof(swi) == 'undefined')
	{
		swi = "1";
		GM_setValue("swi_"+server, "1");
	}

	
	
	
	
	
    var newFlag = document.createElement("reload2"); // On cr�e un nouvelle �l�ment div
    newFlag.setAttribute("style", "position:relative; right:10px;  top:14px" );
    var inner =
	"<img width='25px' height='25px' title='Changer de Channel de Shoutbox' src='http://board.ogame.fr/wcf/icon/infoM.png' id='reload3' />"+
	"<img width='25px' height='25px' title='Affiche/Masque la ShoutBox Lmdb' src='http://xat.com/images/b_groups.gif' id='reload2' />"+
	"<img width='25px' height='25px' title='Intervertit de droite à gauche la Shoutbox Lmdb' src='http://xat.com/images/b_trade.gif' id='switch' /><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	inner += sbival;
    
	newFlag.setAttribute('id', 'toto33');
	newFlag.innerHTML = inner;	
	box = document.getElementById("clearAdvice");
	box.appendChild(newFlag); 

  
		
    document.getElementById("reload2").addEventListener("click", test, true);
	document.getElementById("reload3").addEventListener("click", switchchan, true);
	document.getElementById("switch").addEventListener("click", switchaffichage, true);


	if (pos == "on")
	{
		AffichageChat()
	}


	
	
	
function AffichageChat() {
	
	
    var p = document.createElement("div");
  
   swi = GM_getValue("swi_"+server);
   chat = "";

 if (swi == "1")
 {
   if(screen.width >= 1600)
		{
			var element = document.getElementById('rechts');  //Pour permuter l'image
			var boxx = document.getElementById("box");	
			boxx.setAttribute('style','width:1000px');
			var boxxbg = document.getElementsByClassName("contentBoxBody")[0];	
			boxxbg.setAttribute('style','left:0px');
			
			chat =  '<iframe src='+sbi+' width="300" height="650" frameborder="0" allowtransparency="true"></iframe>';
			p.setAttribute('style', 'position:absolute; right:-150px; top: 30px; width: 146px; height: 651px;z-index: 1; allowtransparency="true";');
		}	
	else if(screen.width >= 1366)
		{
			var element = document.getElementById('helper');  //Pour permuter l'image
			var boxx = document.getElementById("box");	
			boxx.setAttribute('style','width:1000px');
			var boxxbg = document.getElementsByClassName("contentBoxBody")[0];	
			boxxbg.setAttribute('style','left:180px');	
			
			chat =  '<iframe src='+sbi+' width="300" height="650" frameborder="0" allowtransparency="true"></iframe>';
			p.setAttribute('style', 'position:absolute; right:-150px; top: 30px; width: 146px; height: 651px;z-index: 1; allowtransparency="true";');
		}
	else
		{
			var element = document.getElementById('helper');  //Pour permuter l'image
			var boxx = document.getElementById("box");	
			boxx.setAttribute('style','width:1000px');
			var boxxbg = document.getElementsByClassName("contentBoxBody")[0];	
			boxxbg.setAttribute('style','left:180px');	
			
			chat =  '<iframe src='+sbi+' width="200" height="650" frameborder="0" allowtransparency="true"></iframe>';
			p.setAttribute('style', 'position:absolute; right:-150px; top: 10px; width: 146px; height: 651px;z-index: 1; allowtransparency="true";');
		}

 }
 else if (swi == "2")
 {
	
  
  if(screen.width >= 1600)
		{
			var element = document.getElementById('rechts');  //Pour permuter l'image
			var boxx = document.getElementById("box");	
			boxx.setAttribute('style','width:1000px');
			var boxxbg = document.getElementsByClassName("contentBoxBody")[0];	
			boxxbg.setAttribute('style','left:0px');

			chat =  '<iframe src='+sbi+' width="300" height="650" frameborder="0" allowtransparency="true"></iframe>';
			p.setAttribute('style', 'position:absolute; right:-150px; top: 30px; width: 146px; height: 651px;z-index: 1; allowtransparency="true";');
		}
	else if(screen.width >= 1366)
		{
			var element = document.getElementById('helper');  //Pour permuter l'image
			var boxx = document.getElementById("box");	
			boxx.setAttribute('style','width:1200px');
			var boxxbg = document.getElementsByClassName("contentBoxBody")[0];	
			boxxbg.setAttribute('style','left:0px');
			
			chat =  '<iframe src='+sbi+' width="300" height="650" frameborder="0" allowtransparency="true"></iframe>';
			p.setAttribute('style', 'position:absolute; right:-160px; top: 30px; width: 146px; height: 651px;z-index: 1; allowtransparency="true";');
		} 
	else
		{
			var element = document.getElementById('helper');  //Pour permuter l'image
			var boxx = document.getElementById("box");	
			boxx.setAttribute('style','width:1200px');
			var boxxbg = document.getElementsByClassName("contentBoxBody")[0];	
			boxxbg.setAttribute('style','left:0px');
			
			chat =  '<iframe src='+sbi+' width="200" height="650" frameborder="0" allowtransparency="true"></iframe>';
			p.setAttribute('style', 'position:absolute; right:-160px; top: 10px; width: 146px; height: 651px;z-index: 1; allowtransparency="true";');
		} 


 }else if (swi == "3")
 {
	var element = document.getElementById('rechts');  //Pour permuter l'image
	var boxx = document.getElementById("box");	
	boxx.setAttribute('style','width:1000px');
	var boxxbg = document.getElementsByClassName("contentBoxBody")[0];	
	boxxbg.setAttribute('style','left:0px');
  
    if(screen.width >= 1600)
		{
			chat =  '<iframe src='+sbi+' width="300" height="650" frameborder="0" allowtransparency="true"></iframe>';
			p.setAttribute('style', 'position:absolute; right:-160px; top: 30px; width: 146px; height: 651px;z-index: 1; allowtransparency="true";');
		}	
	else if(screen.width >= 1366)
		{
		chat =  '<iframe src='+sbi+' width="300" height="650" frameborder="0" allowtransparency="true"></iframe>';
		p.setAttribute('style', 'position:absolute; right:-160px; top: 30px; width: 146px; height: 651px;z-index: 1; allowtransparency="true";');
		} 
	else
		{
		chat =  '<iframe src='+sbi+' width="200" height="650" frameborder="0" allowtransparency="true"></iframe>';
		p.setAttribute('style', 'position:absolute; right:-160px; top: 10px; width: 146px; height: 651px;z-index: 1; allowtransparency="true";');
		}

 }else if (swi == "4")
 {
	var element = document.getElementById('rechts');  //Pour permuter l'image
	var boxx = document.getElementById("box");	
	boxx.setAttribute('style','width:1000px');
	var boxxbg = document.getElementsByClassName("contentBoxBody")[0];	
	boxxbg.setAttribute('style','left:0px');
  
  if(screen.width >= 1600)
		{
			chat =  '<iframe src='+sbi+' width="300" height="650" frameborder="0" allowtransparency="true"></iframe>';
			p.setAttribute('style', 'position:absolute; right:-160px; top: 30px; width: 146px; height: 651px;z-index: 1; allowtransparency="true";');
		}
	else if(screen.width >= 1366)
		{
			chat =  '<iframe src='+sbi+' width="300" height="650" frameborder="0" allowtransparency="true"></iframe>';
			p.setAttribute('style', 'position:absolute; right:-150px; top: 30px; width: 146px; height: 651px;z-index: 1; allowtransparency="true";');
		}
	else
		{
			chat =  '<iframe src='+sbi+' width="200" height="650" frameborder="0" allowtransparency="true"></iframe>';
			p.setAttribute('style', 'position:absolute; right:-150px; top: 10px; width: 146px; height: 651px;z-index: 1; allowtransparency="true";');
		}
	
 }
 
  p.innerHTML = chat;
  p.setAttribute('id', 'toto');
  element.appendChild(p);

};





function test() {

  var element22 = document.getElementById("toto");  //Pour permuter l'image
	
	if (pos == "on")
	{
	pos = "off";
	GM_setValue("pos_"+server, "off");
	element22.parentNode.removeChild(element22);
	
	var boxx = document.getElementById("box");	
	boxx.setAttribute('style','width:1000px');
	var boxxbg = document.getElementsByClassName("contentBoxBody")[0];	
	boxxbg.setAttribute('style','left:0px');
   	}
	else
	{
	pos = "on";
	GM_setValue("pos_"+server, "on");
	AffichageChat()
	}

  };


  
  function switchaffichage() {

	swi = GM_getValue("swi_"+server);

	var element22 = document.getElementById("toto");  //Pour permuter l'image
	element22.parentNode.removeChild(element22);

	
	if (swi == "1")
	{
	swi = "2";
	GM_setValue("swi_"+server, "2");
   	}
	else if (swi == "2")
	{
	swi = "3";
	GM_setValue("swi_"+server, "3");
	}
	else if (swi == "3")
	{
	swi = "4";
	GM_setValue("swi_"+server, "4");
	}
	else if (swi == "4")
	{
	swi = "1";
	GM_setValue("swi_"+server, "1");
	}
	AffichageChat()

  };



  function switchchan() {

	swi = GM_getValue("swi_"+server);

    sbival = prompt('Changer votre numéro de shoutbox ?',sbival);
	GM_setValue("sbival_"+server, sbival);
    sbi = "http://www.i-tchat.com/shoutbox/shoutbox.php?idShoutbox="+sbival;
	
    var element22 = document.getElementById("toto");  
	element22.parentNode.removeChild(element22);
    AffichageChat()	



    var element33 = document.getElementById("toto33");  //Pour permuter l'image
	element33.parentNode.removeChild(element33);

	
	newFlag = document.createElement("reload2"); // On cr�e un nouvelle �l�ment div
    newFlag.setAttribute("style", "position:relative; right:5px;  top:1px" );
	
	var inner =
	"<img width='25px' height='25px' title='Changer de Channel de Shoutbox'>"+
	"<img width='25px' height='25px' title='Affiche/Masque la ShoutBox Lmdb' src='http://xat.com/images/b_groups.gif' id='reload2' />"+
	"<img width='25px' height='25px' title='Intervertit de droite à gauche la Shoutbox Lmdb'  /><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	inner += sbival;

	newFlag.setAttribute('id', 'toto33');
	newFlag.innerHTML = inner;	
	box = document.getElementById("clearAdvice");
	box.appendChild(newFlag); 

	document.getElementById("reload2").addEventListener("click", test, true);
	document.getElementById("reload3").addEventListener("click", switchchan, true);
	document.getElementById("switch").addEventListener("click", switchaffichage, true);
 
	 
  };