Je suis un fan de création de scripts mais je ne sais pas comment faire, quelqu'un pourrait m'expliquer ou m'apprendre
![Clin d’oeil ;)](./images/smilies/icon_e_wink.gif)
// ==UserScript==
// @name Grepolis Gtio2.0Tools (Version Francaise par JBGO)
// @namespace
// @description Toolkit (script) pour la version 2.0 pour fr.grepolis.com
// @version 0.2.2
// @include http://fr18.grepolis.*/game/index*
// @include http://fr19.grepolis.*/game/index*
// @include http://fr20.grepolis.*/game/index*
// @include http://fr21.grepolis.*/game/index*
// @include http://fr22.grepolis.*/game/index*
// @include http://fr23.grepolis.*/game/index*
// @include http://fr24.grepolis.*/game/index*
// @include http://fr25.grepolis.*/game/index*
// ==/UserScript==
// Modul Debug gt_db
if (true)
{
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);
}
// Modul Static gt_st
if (true)
{
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=='POST')\
{\
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=='POST')\
{\
var data=unescape(settings.data);\
data=data.replace(/json=/,'');\
var dataj=$.parseJSON(data);\
gt_agsb_playerwndprocess(dataj.player_id);\
return;\
}\
if (url=='/game/town_overviews?action=culture_overview' && settings.type=='POST')\
{\
gt_ko_process();\
}\
};\
$('body').ajaxComplete(gt_st_ajaxComplete);\
"));
document.body.appendChild(scriptEl);
}
// Modul AddTownId gt_ati
if (true)
{
var scriptEl = document.createElement("script");
scriptEl.setAttribute('type','text/javascript');
scriptEl.appendChild(document.createTextNode("\
function gt_ati_process(townid)\
{\
if (gt_cfg_townid==0) return;\
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>Id: ('+townid+')</span>');\
}\
"));
document.body.appendChild(scriptEl);
}
// Modul AddGSButton gt_agsb
if (true)
{
var scriptEl = document.createElement("script");
scriptEl.setAttribute('type','text/javascript');
scriptEl.appendChild(document.createTextNode("\
function gt_agsb_townwndprocess()\
{\
if (gt_cfg_gsbutton==0) return;\
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://fr.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','80px');\
}\
function gt_agsb_playerwndprocess(playerid)\
{\
if (gt_cfg_gsbutton==0) return;\
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://de.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);
}
// Modul KulturOverview gt_ko
if (true)
{
var scriptEl = document.createElement("script");
scriptEl.setAttribute('type','text/javascript');
scriptEl.appendChild(document.createTextNode("\
function gt_ko_process()\
{\
gt_db_Debug('Start Processing Culture');\
\
var ela,elli,eltext,elul,eletaspan;\
gt_st_comment='Sortieren der Feste';\
elul=$('UL#culture_overview_towns');\
ela=$('A[class=\\\'confirm type_games \\\']');\
for (var i=0; i<ela.length; i++)\
{\
elli=$(ela[i]).parents('LI[id^=\\\'ov_town_\\\']');\
eltext=elli[0].previousSibling;\
elul[0].insertBefore(elli[0], elul[0].firstChild);\
elul[0].insertBefore(eltext, elul[0].firstChild);\
}\
ela=$('A[class=\\\'confirm type_party \\\']');\
for (var i=0; i<ela.length; i++)\
{\
elli=$(ela[i]).parents('LI[id^=\\\'ov_town_\\\']');\
eltext=elli[0].previousSibling;\
elul[0].insertBefore(elli[0], elul[0].firstChild);\
elul[0].insertBefore(eltext, elul[0].firstChild);\
}\
\
gt_st_comment='Feste zaehlen f?r Statusleiste';\
eletaspan=$('UL#culture_overview_towns SPAN.eta');\
var cc=$('DIV#place_culture_count').text();\
var points=cc.split('/');\
var newpoints=parseInt(points[0],10)+eletaspan.length;\
var diffpoints=parseInt(points[1],10)-newpoints;\
if (diffpoints>0)\
{\
$('DIV#place_culture_count').text(points[0]+'/'+points[1]+' [-'+diffpoints+']');\
}\
else\
{\
var allEtas=new Array();\
for (var i=0; i<eletaspan.length; i++)\
{\
allEtas.push($(eletaspan[i]).text());\
gt_db_Debug(allEtas[i]);\
}\
gt_db_Debug('ael:'+allEtas.length+' dp:'+diffpoints);\
allEtas.sort();\
var eta=allEtas[allEtas.length + diffpoints -1];\
gt_db_Debug('eta '+eta);\
$('DIV#place_culture_count').html(points[0]+'/'+points[1]+' [<span></span>]');\
$('DIV#place_culture_count span').countdown( eta );\
$('DIV#place_culture_count span').mousePopup( new MousePopup( 'Zeit bis zum Erreichen der n?chsten Stufe' ) );\
}\
};\
"));
document.body.appendChild(scriptEl);
}
// Modul Konfiguration gt_cfg
if (true)
{
var scriptEl = document.createElement("script");
scriptEl.setAttribute('type','text/javascript');
scriptEl.appendChild(document.createTextNode("\
var gt_cfg_townid=1;\
var gt_cfg_gsbutton=1;\
var gt_cfg_kultur=1;\
var gt_cfg_befehle=0;\
var gt_cfg_gunst=0;\
var gt_cfg_forum=0;\
var gt_cfg_balancedload=0;\
"));
document.body.appendChild(scriptEl);
}
! | JBGO a écrit: |
Evite l'écriture en blanc ![]() |