IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

script sur toutes les pages !


Sujet :

JavaScript

  1. #1
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Juin 2011
    Messages
    148
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juin 2011
    Messages : 148
    Points : 54
    Points
    54
    Par défaut script sur toutes les pages !
    Bonsoir,

    Je voudrais que le script ci-dessous s'affiche QUE sur la page http://*.grepolis.*/game/*

    Voici le script installé :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    // ==UserScript==
    // @name          Grepolis Outils
    // @author        Sayunu (Version Francaise par JBGO et AZBOY)
    // @licence       Copyright JBGO, Tous droits reserves 2011+
    // @version       1.6
    // @include       http://fr1.grepolis.*/game/*
    // ==/UserScript==
    
    
    (code du jquery)
    
    var h = document.createElement('script');
        h.src = 'http://dl.dropbox.com/u/42018124/scripts/sayunu/scriptv2sayunchrome.user.js';
        h.type = 'text/javascript';
        document.getElementsByTagName('head')[0].appendChild(h);
    avec le script ici :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $(document).ready(function(){var script=document.createElement('script');script.id='hotkey';script.type='text/javascript';script.src='http://dl.dropbox.com/u/42018124/scripts/sayunu/shortcut.js';document.getElementsByTagName("head")[0].appendChild(script);var divh=document.createElement('div');divh.setAttribute("onmouseover","ajuda();");divh.setAttribute("onmouseout","ajuda2();");divh.style.zIndex='10';divh.id='hk';divh.style.position='absolute';divh.style.top='25px';divh.style.left='471px';divh.style.height='45px';divh.style.width='35px';divh.style.backgroundImage='url(http://dl.dropbox.com/u/42018124/scripts/sayunu/bouton.gif)';divh.style.backgroundColor='';document.body.appendChild(divh);$('<div id="menu12" style="z-index:100;position:relative;width:133px;height:74px;"></div>').appendTo('#units_sidebar');$("#menu12").css("background-image","url(http://allykx1.no.sapo.pt/menu19.png)");$('<a id="alarmea" style="color:#FC6;padding-left:10px" href=" " >Alarme</a><br/>').appendTo('#menu12');$('#alarmea').attr('onclick','javascript:$.getScript("http://dl.dropbox.com/u/42018124/scripts/sayunu/alarm.js")');$('<a id="culturaa" style="color:#FC6;padding-left:10px" href=" " >Culture</a><br/>').appendTo('#menu12');$('#culturaa').attr('onclick','javascript:$.getScript("http://dl.dropbox.com/u/42018124/scripts/sayunu/culture.js")');$('<a id="fulla" style="color:#FC6;padding-left:10px" href=" " >Plein &eacute;cran</a>').appendTo('#menu12');$('#fulla').attr('onclick','javascript:$.getScript("http://dl.dropbox.com/u/42018124/scripts/sayunu/fullscreen.js")');var mundo=/:\/\/([^./]+)/.exec(window.location.href)[1];$('<div id="uus" style="padding-top:2px;z-index:100;position:absolute;width:162px;height:34px;top:529px;left:0px;"></div>').appendTo('body');$("#uus").css("background-image","url(http://allykx1.no.sapo.pt/uf.png)");$('<a id="al1" style="z-index:101;position:absolute;width:24px;height:20px;top:543px;left:4px;" href="http://www.fr.grepostats.com/world/'+mundo+'/index" target="_blank"><img src="http://allykx1.no.sapo.pt/ugs.png" style="border-width: 0px" /></a>').appendTo('body');$('<a id="al2" style="z-index:101;position:absolute;width:24px;height:20px;top:543px;left:37px;" href="http://fr.grepo-world.com/" target="_blank"><img src="http://allykx1.no.sapo.pt/ugw.png" style="border-width: 0px" /></a>').appendTo('body');$('<a id="al3" style="z-index:101;position:absolute;width:24px;height:20px;top:543px;left:70px;" href="http://'+mundo+'.grepolismaps.org/" target="_blank"><img src="http://allykx1.no.sapo.pt/umaps.png" style="border-width: 0px" /></a>').appendTo('body');$('<a id="al4" style="z-index:101;position:absolute;width:24px;height:20px;top:543px;left:136px;" href="http://'+mundo+'.grepolis.com/forum" target="_blank"><img src="http://allykx1.no.sapo.pt/uforum.png" style="border-width: 0px" /></a>').appendTo('body');$('<a id="al5" style="z-index:101;position:absolute;width:24px;height:20px;top:543px;left:103px;" href="http://www.grepoutils.webxxs.com/grepolis-utilitaires/" target="_blank"><img src="http://allykx1.no.sapo.pt/utk.png" style="border-width: 0px" /></a>').appendTo('body')});var scriptEl=document.createElement("script");scriptEl.setAttribute('type','text/javascript');scriptEl.appendChild(document.createTextNode("	var gt_db_debugger=false;	var gt_db_content=new Array();	var gt_db_MaxContentLength=14;	function gt_db_FormatTime(t)	{		var h=t.getHours();		if (h<10) h='0'+h;		var m=t.getMinutes();		if (m<10) m='0'+m;		var s=t.getSeconds();		if (s<10) s='0'+s;		return h+':'+m+':'+s;	};	function gt_db_RefreshContent()	{		if (!gt_db_debugger) return;		var gt_wnd;		gt_wnd=GPWindowMgr.getOpenFirst(Layout.wnd.TYPE_CUSTOM);		if (!gt_wnd)		{			Layout.wnd.Create(Layout.wnd.TYPE_CUSTOM, 'G.Tio Tools Console');			gt_wnd=GPWindowMgr.getOpenFirst(Layout.wnd.TYPE_CUSTOM);		}		if (gt_db_content.length==gt_db_MaxContentLength)		{			gt_db_content.shift();		}		var gt_temp_content='';		for (var i=0; i<gt_db_content.length; i++)		{			gt_temp_content=gt_temp_content+gt_db_content[i];		}		gt_wnd.setContent(gt_temp_content);	}	function gt_db_Debug(message)	{		var now=new Date();		gt_db_content.push(gt_db_FormatTime(now)+' '+message+'<br>');		gt_db_RefreshContent();	};	(function(){		gt_db_content.push('Tools startet...<br>');		window.setTimeout(gt_db_RefreshContent, 3000);	})();	"));document.body.appendChild(scriptEl);var scriptEl=document.createElement("script");scriptEl.setAttribute('type','text/javascript');scriptEl.appendChild(document.createTextNode("	function gt_st_ajaxComplete(e, xhr, settings)	{		var url=settings.url.split(/&/)[0];		if (url=='/game/town_info?action=info' && settings.type=='GET')		{			var data=unescape(settings.data);			data=data.replace(/json=/,'');			var dataj=$.parseJSON(data);			gt_db_Debug('towninfo requested for '+dataj.id);			gt_ati_process(dataj.id);			gt_agsb_townwndprocess();			return;		}		if (url=='/game/player?action=get_profile_html' && settings.type=='GET')		{			var data=unescape(settings.data);			data=data.replace(/json=/,'');			var dataj=$.parseJSON(data);			gt_agsb_playerwndprocess(dataj.player_id);			return;		}		if (url=='/game/town_info?action=attack' || url=='/game/town_info?action=support')		{			gt_bl_initWnd();		}		if (url=='/game/island_info?action=index')		{			$('.col1').append('<div><a onclick=javascript:$.getScript(\\\'http://allykx1.no.sapo.pt/user/ilha1.js\\\') href=#>Message a l ile</a></div>');		}	};	$('body').ajaxComplete(gt_st_ajaxComplete);"));document.body.appendChild(scriptEl);var scriptEl=document.createElement("script");scriptEl.setAttribute('type','text/javascript');scriptEl.appendChild(document.createTextNode("	function gt_ati_process(townid)	{		var wnds=GPWindowMgr.getOpen(Layout.wnd.TYPE_TOWN);		if (wnds.length==0)		{			return;		}		var wnd=wnds[wnds.length-1];		var wndid=wnd.getID();		var testel=$('DIV#gpwnd_'+wndid+' DIV#towninfo_towninfo DIV.game_header.bold SPAN.gt_townid');		if (testel.length>0)			return;		var div=$('DIV#gpwnd_'+wndid+' DIV#towninfo_towninfo DIV.game_header.bold');		$(div[0]).append('<span class=gt_townid>[town]'+townid+'[/town]</span>');	}"));document.body.appendChild(scriptEl);var scriptEl=document.createElement("script");scriptEl.setAttribute('type','text/javascript');scriptEl.appendChild(document.createTextNode("	function gt_agsb_townwndprocess()	{		var wnds=GPWindowMgr.getOpen(Layout.wnd.TYPE_TOWN);		if (wnds.length==0)		{			return;		}		var wnd=wnds[wnds.length-1];		var wndid=wnd.getID();		var testel=$('DIV#gpwnd_'+wndid+' DIV#towninfo_towninfo UL.game_list DIV.list_item_right SPAN.gt_gsbutton');		if (testel.length>0)			return;		var href=$('DIV#gpwnd_'+wndid+' DIV#towninfo_towninfo A.gp_player_link').attr('href');		var arr=href.split(/#/);		var data=$.parseJSON(atob(arr[1] || arr[0]));		var world=window.location.host.replace(/.grepolis.com.*$/,'');		var awrite=$('DIV#gpwnd_'+wndid+' DIV#towninfo_towninfo UL.game_list DIV.list_item_right');		$(awrite[0]).append('<span class=gt_gsbutton><a target=_blank href=http://www.grepostats.com/world/'+world+'/player/'+data.id+'><img src=http://grepo.faark.de/faarksGrepoTools/resources/view_on_grepostats.png style=\\\'padding-top:1px; padding-left:3px\\\'></a></span>');		$(awrite[0]).css('width','99px');	}	function gt_agsb_playerwndprocess(playerid)	{		gt_db_Debug('agsb for '+playerid);		var gt_wnd;		gt_wnd=GPWindowMgr.getOpenFirst(Layout.wnd.TYPE_PLAYER_PROFILE);		if (!gt_wnd)		{			return;		}		var div=$('DIV#gpwnd_'+gt_wnd.getID()+' DIV#player_buttons ');		var world=window.location.host.replace(/.grepolis.com.*$/,'');		$(div[0]).append('<a target=_blank href=http://www.grepostats.com/world/'+world+'/player/'+playerid+'><img src=http://grepo.faark.de/faarksGrepoTools/resources/view_on_grepostats.png style=\\\'padding-top:1px; padding-left:3px\\\'></a>');	}"));document.body.appendChild(scriptEl);var scriptEl=document.createElement("script");scriptEl.setAttribute('type','text/javascript');scriptEl.appendChild(document.createTextNode("	var gt_bl_unitPopulation={sword:1,slinger:1,archer:1,hoplite:1,rider:3,chariot:4,catapult:15,minotaur:30,zyklop:40,medusa:18,cerberus:30,fury:55,centaur:12};	var gt_bl_groundUnits=new Array('sword','slinger','archer','hoplite','rider','chariot','catapult','minotaur','zyklop','medusa','cerberus','fury','centaur');	function gt_bl_process(wndid)	{		var wnd=GPWindowMgr.GetByID(wndid);		if (!wnd)			return;		var handler=wnd.getHandler();		if (!handler)			return;		var units=new Array();		var item;		for (var i=0; i<gt_bl_groundUnits.length; i++)		{			if (handler.data.units[gt_bl_groundUnits[i]])			{				item={name:gt_bl_groundUnits[i], count:handler.data.units[gt_bl_groundUnits[i]].count, population:handler.data.units[gt_bl_groundUnits[i]].population};				units.push(item);			}		}		if (handler.data.researches && handler.data.researches.berth)			var berth=handler.data.researches.berth;		else			var berth=0;		var totalCap=handler.data.units.big_transporter.count*(handler.data.units.big_transporter.capacity+berth)+handler.data.units.small_transporter.count*(handler.data.units.small_transporter.capacity+berth);						units.sort(function(a,b){			return b.population-a.population;		});		for (i=0; i<units.length; i++)			gt_db_Debug('i='+i+ ' name='+units[i].name+' pop='+units[i].population+' c='+units[i].count);		for (i=0; i<units.length; i++)			if (units[i].count==0)			{				units.splice(i,1);				i=i-1;			};		gt_db_Debug('---');		for (i=0; i<units.length; i++)			gt_db_Debug('i='+i+ ' name='+units[i].name+' pop='+units[i].population+' c='+units[i].count);								var restCap=totalCap;		var sendUnits=new Array();		for (i=0; i<units.length; i++)		{			item={name:units[i].name, count:0};			sendUnits[units[i].name]=item;		};		for (j=0; j<gt_bl_groundUnits.length; j++)		{			if (sendUnits[gt_bl_groundUnits[j]])				gt_db_Debug(sendUnits[gt_bl_groundUnits[j]].name+' '+sendUnits[gt_bl_groundUnits[j]].count);		}						var hasSent;		k=0;		while (units.length>0)		{			hasSent=false;			k=k+1;			for (i=0; i<units.length; i++)			{				if (units[i].population<=restCap)				{					hasSent=true;					units[i].count=units[i].count-1;					sendUnits[units[i].name].count=sendUnits[units[i].name].count+1;					restCap=restCap-units[i].population;				}			}			for (i=0; i<units.length; i++)				if (units[i].count==0)				{					units.splice(i,1);					i=i-1;				};			if (!hasSent)			{				gt_db_Debug('Abbruch nach '+k+' loops');				break;			}		}		gt_db_Debug('nach '+k+'---- rest='+restCap);		for (i=0; i<gt_bl_groundUnits.length; i++)		{			if (sendUnits[gt_bl_groundUnits[i]])				gt_db_Debug(sendUnits[gt_bl_groundUnits[i]].name+' '+sendUnits[gt_bl_groundUnits[i]].count);		}		handler.getUnitInputs().each(function ()		{			if (!sendUnits[this.name])			{				if (handler.data.units[this.name].count>0)					this.value=handler.data.units[this.name].count;				else					this.value='';			}		});		for (i=0; i<gt_bl_groundUnits.length; i++)		{			if (sendUnits[gt_bl_groundUnits[i]])			{				if (sendUnits[gt_bl_groundUnits[i]].count>0)					$('DIV#gpwnd_'+wndid+' INPUT.unit_type_'+gt_bl_groundUnits[i]).val(sendUnits[gt_bl_groundUnits[i]].count);				else					$('DIV#gpwnd_'+wndid+' INPUT.unit_type_'+gt_bl_groundUnits[i]).val('');			}		}		$('DIV#gpwnd_'+wndid+' INPUT.unit_type_sword').trigger('change');	}	function gt_bl_delete(wndid)	{		var wnd=GPWindowMgr.GetByID(wndid);		if (!wnd)			return;		var handler=wnd.getHandler();		if (!handler)			return;		handler.getUnitInputs().each(function ()		{			this.value='';		});		$('DIV#gpwnd_'+wndid+' INPUT.unit_type_sword').trigger('change');	}	function gt_bl_initWnd()	{		var wnds=GPWindowMgr.getOpen(Layout.wnd.TYPE_TOWN);		if (wnds.length==0)		{			return;		}		var testel=$('DIV#gpwnd_'+wndid+' A.gt_balanced');		if (testel.length>0) return;		var wnd=wnds[wnds.length-1];		var wndid=wnd.getID();		var ael=$('DIV#gpwnd_'+wndid+' A.select_all_units');		$(ael).after('&nbsp;|&nbsp;<a class=gt_balanced style=\\\'position:relative; top:3px\\\' href=javascript:gt_bl_process('+wndid+')>Distribuer</a>		&nbsp;|&nbsp;<a style=\\\'position:relative; top:3px\\\' href=javascript:gt_bl_delete('+wndid+')>Supprimer</a>');	}"));document.body.appendChild(scriptEl);
    Les éléments (create) s'affiche partout ! Même sans le header greasemonkey !!

    HELP !

  2. #2
    Expert éminent
    Avatar de Watilin
    Homme Profil pro
    En recherche d'emploi
    Inscrit en
    Juin 2010
    Messages
    3 094
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : En recherche d'emploi

    Informations forums :
    Inscription : Juin 2010
    Messages : 3 094
    Points : 6 755
    Points
    6 755
    Par défaut
    Citation Envoyé par MRJBGO Voir le message
    Bonsoir,

    Je voudrais que le script ci-dessous s'affiche QUE sur la page http://*.grepolis.*/game/*
    Actuellement, c'est exactement ce que fait ton script

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    // @include       http://fr1.grepolis.*/game/*
    Les éléments (create) s'affiche partout ! Même sans le header greasemonkey !!
    Là doit y avoir un problème. Tu es sûr d'avoir correctement installé le script ? Tu as quelle version de Firefox et de GreaseMonkey ?

  3. #3
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Juin 2011
    Messages
    148
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juin 2011
    Messages : 148
    Points : 54
    Points
    54
    Par défaut
    Dès que le script est à distance ... ça le met sur tout les sites ...

    Je suis sous chrome marche très bien avec Tampermonkey mais je voudrais le faire marcher sans

    J'essai aussi essayé match, rien

  4. #4
    Expert éminent
    Avatar de Watilin
    Homme Profil pro
    En recherche d'emploi
    Inscrit en
    Juin 2010
    Messages
    3 094
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : En recherche d'emploi

    Informations forums :
    Inscription : Juin 2010
    Messages : 3 094
    Points : 6 755
    Points
    6 755
    Par défaut
    Je ne connais pas Tampermonkey, je ne peux pas t'aider. Tu devrais aller voir sur http://forum.tampermonkey.net/

  5. #5
    Membre expérimenté Avatar de Willpower
    Homme Profil pro
    sans emploi
    Inscrit en
    Décembre 2010
    Messages
    1 009
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : sans emploi

    Informations forums :
    Inscription : Décembre 2010
    Messages : 1 009
    Points : 1 519
    Points
    1 519
    Par défaut
    Citation Envoyé par Watilin Voir le message
    Actuellement, c'est exactement ce que fait ton script

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    // @include       http://fr1.grepolis.*/game/*
    je ne peux que confirmer, par défaut sous chrome le bon mot clé est "match" mais il accepte également le "include" de greasemonkey.

    si ton script se lance aussi sur d'autres sites, vérifie peut-être que tu n'as pas une vieille version d'installée qui elle se lancerait sur tous les sites ?

Discussions similaires

  1. [Etat] Valeurs non visibles sur toutes les pages
    Par wperezrobles dans le forum IHM
    Réponses: 6
    Dernier message: 17/10/2006, 14h12
  2. [css]ecrire sur toutes les pages
    Par despe59 dans le forum Mise en page CSS
    Réponses: 3
    Dernier message: 28/06/2006, 14h01
  3. Réponses: 9
    Dernier message: 29/03/2006, 21h41
  4. La date sur toutes les pages
    Par philippef dans le forum Général JavaScript
    Réponses: 16
    Dernier message: 07/02/2006, 17h44

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo