Author Topic: Dragosim & redesign  (Read 3293 times)

Offline aldaris

  • Newbie
  • *
  • Posts: 16
  • Karma: 0
Dragosim & redesign
« on: June 28, 2010, 11:18:31 AM »
Hi all,

I've noticed that the script dragosim doesn't work anymore with the new new version of ogame.
MrMage can you adapt your very usefull greasemonkey script please  :D.

Offline MrMage

  • Administrator
  • *****
  • Posts: 470
  • Karma: 7
Re: Dragosim & redesign
« Reply #1 on: June 28, 2010, 06:34:30 PM »
Hi,

At the moment, I don't have an OGame account, so I can't upgrade the script. But you may try some of the other scripts, like http://ogameuniverse.de/ogameskript.html http://www.foxgame.de/ http://userscripts.org/scripts/show/69082 or http://www.neogame.dk/index.en.php

Please let me know if any of them work.

Cheers

MrMage
« Last Edit: June 28, 2010, 06:43:11 PM by MrMage »

Offline aldaris

  • Newbie
  • *
  • Posts: 16
  • Karma: 0
Re: Dragosim & redesign
« Reply #2 on: June 28, 2010, 06:38:46 PM »
Ok I will try these scripts but all the links you give are 404 errors.
I will try to find some french or english script.

Offline MrMage

  • Administrator
  • *****
  • Posts: 470
  • Karma: 7
Re: Dragosim & redesign
« Reply #3 on: June 28, 2010, 06:43:38 PM »
I updated the links. If any of these scripts work (some of them are german), I might adapt the DragoSim script.

Offline aldaris

  • Newbie
  • *
  • Posts: 16
  • Karma: 0
Re: Dragosim & redesign
« Reply #4 on: June 28, 2010, 06:59:55 PM »
All of these scripts don't work.
But one called anti game which is like foxgame. It's works with greasemonkey.

Offline MrMage

  • Administrator
  • *****
  • Posts: 470
  • Karma: 7
Re: Dragosim & redesign
« Reply #5 on: June 28, 2010, 07:05:56 PM »
And it also supports DragoSim?

Offline aldaris

  • Newbie
  • *
  • Posts: 16
  • Karma: 0
Re: Dragosim & redesign
« Reply #6 on: June 28, 2010, 07:13:55 PM »
It adds a link to websim ^^
But not to dragosim.

Offline aldaris

  • Newbie
  • *
  • Posts: 16
  • Karma: 0
Re: Dragosim & redesign
« Reply #7 on: June 28, 2010, 07:15:25 PM »
I can edit the code to change the url and to use dragosim  ;)

Offline aldaris

  • Newbie
  • *
  • Posts: 16
  • Karma: 0
Re: Dragosim & redesign
« Reply #8 on: June 28, 2010, 07:20:16 PM »
I try to change the url in the code but when I changed this, the button to go to the simulator has disapear.

Offline aldaris

  • Newbie
  • *
  • Posts: 16
  • Karma: 0
Re: Dragosim & redesign
« Reply #9 on: June 28, 2010, 07:25:46 PM »
Yeah it works now, sorry for multi posting but I haven't found the edit button  ;D

Offline MrMage

  • Administrator
  • *****
  • Posts: 470
  • Karma: 7
Re: Dragosim & redesign
« Reply #10 on: June 28, 2010, 07:28:48 PM »
Could you upload your modified version of AntiGame so I can have a look at it?

Offline aldaris

  • Newbie
  • *
  • Posts: 16
  • Karma: 0
Re: Dragosim & redesign
« Reply #11 on: June 29, 2010, 02:13:46 PM »
Ok I've just changed the url and the name of the button.
This is the code for spy reports only the whole code is very very long  :D


Code: [Select]
// =======================================================================
// functions for spy reports processing
// =======================================================================

var SpyReport =
{
readValue: function(cell)
{
return parseInt(cell.innerHTML.replace(/\D/g, ''), 10);
},

insertTable: function(container, mytable)
{
var table = document.createElement('table');
table.className = 'fleetdefbuildings spy plunder';
mytable.title_class = 'area plunder';
mytable.key_class = 'plkey plunder';
mytable.value_class = 'plvalue plunder';
table.innerHTML = mytable.createTableString(2);

container.appendChild(table);
},

calculatePlunder: function(report)
{
this.metal = this.crystal = this.deuterium =
this.plunder_metal = this.plunder_crystal = this.plunder_deuterium = 0;

var cells = Utils.XPath('descendant::*[contains(@class,"fragment")]/descendant::TD', report);

this.metal = this.readValue(cells.snapshotItem(1));
this.crystal = this.readValue(cells.snapshotItem(3));
this.deuterium = this.readValue(cells.snapshotItem(5));

this.plunder_metal =  this.metal / 2;
this.plunder_crystal = this.crystal / 2;
this.plunder_deuterium = this.deuterium / 2;
},

calculateDebris: function(report)
{
try {
this.debris_metal = this.debris_crystal = 0;

var cells = Utils.XPath('descendant::*[@class="fleetdefbuildings spy"][position()=1 or position()=2]/descendant::*[@class="key"]', report);

var ships = [];
for (var i=0; i<cells.snapshotLength; i++)
{
var cell = cells.snapshotItem(i);
var cntNode  = cell.nextSibling;

ships.push( {name:cell.innerHTML, count:this.readValue(cntNode) } );
}

var debris = Ogame.getFleetDebris(ships, true);
this.debris_metal = debris.metal;
this.debris_crystal = debris.crystal;
} catch (e) { Utils.log(e) }

},

showPlunder: function (report)
{
var total = this.metal + this.crystal + this.deuterium;

var capacity_needed =
Math.max( this.plunder_metal + this.plunder_crystal + this.plunder_deuterium,
Math.min( (2 * this.plunder_metal + this.plunder_crystal + this.plunder_deuterium) * 3 / 4,
(2 * this.plunder_metal + this.plunder_deuterium)
)
);

var small_cargos = Math.ceil(capacity_needed/5000);
var large_cargos = Math.ceil(capacity_needed/25000);

SimpleTable.init(Options.Interface.lbl_resources);
SimpleTable.addCell(Options.Interface.lbl_total, total);
SimpleTable.addCell(Options.Interface.lbl_loot, Math.floor(total/2));
SimpleTable.addCell(Options.Interface.lbl_shipLCargoAlt, large_cargos);
SimpleTable.addCell(Options.Interface.lbl_shipSCargoAlt, small_cargos);

this.insertTable(report, SimpleTable);
},

showDebris: function (report)
{
var total = this.debris_metal + this.debris_crystal;
if (!total) return;

SimpleTable.init(Options.Interface.lbl_debris);
SimpleTable.addCell(Options.Interface.lbl_metal, this.debris_metal);
SimpleTable.addCell(Options.Interface.lbl_crystal, this.debris_crystal);
SimpleTable.addCell(Options.Interface.lbl_total, total);
SimpleTable.addCell(Options.Interface.lbl_shipRecyclerAlt, Math.ceil(total/20000));

this.insertTable(report, SimpleTable);
},

addSimButton: function(report)
{
try {
var dummy = document.createElement('td');
dummy.className = 'dummy';

var attack = Utils.getElementByClassName('attack', report);

attack.parentNode.insertBefore(dummy, attack);
Utils.insertAfter(dummy.cloneNode(false), attack);

var sim = attack.cloneNode(false);
sim.innerHTML = '<a class="buttonSave" href="javascript:void(0)"><span>Dragosim</span></a>';
Utils.insertAfter(sim, attack);

sim.addEventListener('click', function(e){ SpyReport.submitToWebSim(e) }, false);
} catch (e) { Utils.log(e) }
},

createSimForm: function()
{
function addTech(id, param) {
if (Ogame.getTech(id) > -1) SpyReport.sim_form.action += '&'+param+'='+Ogame.getTech(id);
}

var lang = Utils.server_lang.toLowerCase();
if (Utils.server_lang == 'HR') lang = 'ba';
else if (Utils.server == 'US') lang = 'us';

this.sim_form = document.createElement('form');
this.sim_form.id = 'sim_form';
this.sim_form.method = 'POST';
this.sim_form.action = 'http://drago-sim.com/index.php?lang=french'+lang;

// techs
addTech(Ogame.TECH_WEAPONS, 'tech_a0_0');
addTech(Ogame.TECH_SHIELD, 'tech_a0_1');
addTech(Ogame.TECH_ARMOUR, 'tech_a0_2');

// drives
addTech(Ogame.TECH_COMB_DRIVE, 'engine0_0');
addTech(Ogame.TECH_IMPULSE_DRIVE, 'engine0_1');
addTech(Ogame.TECH_HYPER_DRIVE, 'engine0_2');

//coords
var coords = Ogame.getActiveCoords();
if (coords)
this.sim_form.action += '&start_pos='+coords.galaxy+':'+coords.system+':'+coords.planet;

this.sim_form.target = '_Dragosim';
this.sim_form.innerHTML = '<input type="hidden" id="sim_input" name="report" />';
document.body.appendChild(this.sim_form);
},

submitToWebSim: function(evt)
{
if (!this.sim_form)
this.createSimForm();

if (!this.sim_form) return;

var report = evt.target
.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode
.innerHTML.replace(/<[^>]+>|\n/g,'');

this.sim_form.getElementsByTagName('input')[0].value = encodeURI(report);
this.sim_form.submit();
},

insertCSSRules: function()
{
Utils.insertCSSRule(".plkey { width: 30% }");
Utils.insertCSSRule(".plvalue { width: 20% }");
Utils.insertCSSRule(".plunder { border: 1px solid grey !important; }");
Utils.insertCSSRule("table.plunder { border-collapse: collapse; }");
Utils.insertCSSRule(".plkey, .plvalue { padding: 5px !important; }");

Utils.insertCSSRule(".dummy { width: 33% !important; }");
},

Show: function()
{
//this.insertCSSRules();

var container;
if ( Utils.isCurrentPage('showmessage') ) {
container = document.getElementById("messagebox");
} else {
container = document.getElementById("messageContent");
}

var rows = Utils.getElementsByClassName('material spy', container);

for (var i=0; i<rows.snapshotLength; i++) {
var report = rows.snapshotItem(i).parentNode;

this.calculatePlunder(report);
this.calculateDebris(report);

if (Options.msg_PlunderThreshold && Utils.isCurrentPage('messages') ) {
var total_pl = this.plunder_metal + this.plunder_crystal + this.plunder_deuterium;
var total_df = this.debris_metal + this.debris_crystal;
if (total_pl < Options.msg_PlunderThreshold*1000 && total_df < Options.msg_DebrisThreshold*1000)
document.getElementById( report.parentNode.parentNode.id.replace('spioDetails_','')+'TR' ).className += ' smallplunder';
}

if (Options.msg_showPlunder) {
this.showPlunder(report);
this.showDebris(report);
}

if (Options.msg_addSimButton) {
this.addSimButton(report);
}

}
}
}


var Messages =
{
addButtons: function()
{
function insertButton(value, mod, title) {

if (!title && mod>0) {
var opt = Utils.XPathSingle('//SELECT/OPTION[@id="'+mod+'"]');
if (opt) title = opt.innerHTML;
}

var btn = document.createElement('input');
btn.type = 'button';
btn.value = value;

if (mod==12) btn.style.color = '#00CC22';
else if (mod==-12) btn.style.color = '#229922';
else if (mod==7) btn.style.color = '#660011';
else if (mod==-7) btn.style.color = '#993300';
else if (mod==9) btn.style.color = '#990000';

if (title) btn.title = title;
btn.setAttribute('mod', mod);
span.appendChild(btn);
}

// Recycle bin
if (Utils.unsafeWindow.aktCat == 3) return;

var span = document.createElement('span');
span.className = 'msgButtons';

insertButton('V', 12);
insertButton('VV', -12, Options.Interface.lbl_btnMarkReadAll);
insertButton('X', 7);
insertButton('Xx', -7, Options.Interface.lbl_btnDeleteSmallPlunder);
insertButton('XX', 9);

var form = Utils.XPathSingle('//FORM[@name="delMsg"]');
form.parentNode.insertBefore(span, form);

var $ = Utils.$;
Utils.insertAfter( $('.msgButtons').clone(true).get(0), form);
$('.msgButtons input').click(Messages.onButtonClick);

$('.selectContainer')
.clone(true)
.prependTo('#messageContent')
.css({width:'160px',position:'absolute',right:'20px',fontSize:'11px'})
.find('div').eq(0)
.css('float','left');
},

onButtonClick: function()
{
try {
var mod = this.getAttribute('mod');

if (mod>0) {
Utils.unsafeWindow.mod = mod;
Utils.trigger(Utils.getElementByClassName('buttonOK deleteIt'), 'click');
}

else if (mod == -12 || mod == -7) {
var delIds = [];
var classname = ( mod == -12) ? 'trigger new' : 'trigger smallplunder';
var nodes = Utils.getElementsByClassName(classname);

for (var i=0; i<nodes.snapshotLength; i++)
delIds.push( nodes.snapshotItem(i).id.toString().replace(/\D/g, '') );

Utils.unsafeWindow.executeAction(delIds, -mod);
}
} catch (e) { Utils.log(e) }
},

changeTimes: function()
{
if (Utils.isCurrentPage('messages'))
{
DateTime.changeNodesTime(
'//*[@id="mailz"]/TBODY/TR[contains(@class,"entry")]/*[@class="date"]',
'[d].[m].[Y] [H]:[i]:[s]' );

DateTime.changeNodesTime(
'//*[@id="mailz"]/TBODY/TR[contains(@id,"spioDetails")]/descendant::*[@class="material spy"]/TBODY/TR/TH',
'[m]-[d] [H]:[i]:[s]' );
}

else if (Utils.isCurrentPage('showmessage'))
{
DateTime.changeNodesTime(
'//*[contains(@class,"infohead")]/TABLE/TBODY/TR[last()]/TD | '+
'//*[@id="battlereport"]/P',
'[d].[m].[Y] [H]:[i]:[s]' );

DateTime.changeNodesTime(
'//*[@class="material spy"]/TBODY/TR/TH',
'[m]-[d] [H]:[i]:[s]' );
}

},

Show: function(evt)
{
try {
if (evt && ! (evt.target.tagName == 'FORM' && evt.target.name == 'delMsg'))
return;

var need_plunder = false;
if ( Utils.isCurrentPage('messages') && Options.msg_PlunderThreshold && (Options.msg_foldSmallPlunder || Options.msg_addButtons) )
need_plunder = true;

if (Options.msg_showPlunder || need_plunder || Options.msg_addSimButton) {
SpyReport.Show();
}

if (Options.timeSetting == 1) {
Messages.changeTimes();
}

if ( Utils.isCurrentPage('messages') && Options.msg_PlunderThreshold && Options.msg_foldSmallPlunder)
setTimeout( function() { Utils.$('.smallplunder .subject a').trigger('click') }, 0);

if ( Options.msg_addButtons && Utils.isCurrentPage('messages') ) {
Messages.addButtons();
}

if ( Utils.isCurrentPage('showmessage') ) {
var span = Utils.XPathSingle('//DIV[@class="note"]/SPAN[contains(@class,"tips") and @title]');
if (span) {
var text = span.title.toString();
text = text.replace(/<br>$/gi, '').replace(/<br>/gi, ', ').replace(/\|/gi, '');
if (text) span.innerHTML += ' ('+text+')';
}
}
}
catch(e) {
Utils.log(e);
}
},

insertCSSRules: function()
{
if ( Utils.isCurrentPage('messages') ) {
Utils.insertCSSRule('.msgButtons input { ' +
'-moz-background-clip:border;' +
'-moz-background-inline-policy:continuous;' +
'-moz-background-origin:padding;' +
'background:transparent url(./img/layout/formular_buttons.gif) no-repeat scroll -88px -54px;' +
'border:0 none;' +
'color:#0D1014;' +
'cursor:pointer;' +
'font-size:11px;' +
'font-weight:700;' +
'text-align:center;' +
'height: 27px; ' +
'width: 42px; ' +
'}');

Utils.insertCSSRule('.msgButtons input:hover { ' +
'background:transparent url(./img/layout/formular_buttons.gif) no-repeat scroll -88px -80px;' +
'}');

}

SpyReport.insertCSSRules();

},

Run: function()
{
this.insertCSSRules();

if ( Utils.isCurrentPage('messages') ) {
document.getElementById('section2').addEventListener('DOMNodeInserted', this.Show, false);
if (Options.msg_killTips)
Utils.unsafeWindow.initCluetip = function(){};
}
else
this.Show();
}

}



var Network =
{
/*showMemberScores: function()
{
try {
var items = Utils.XPath('//*[@class="member_score"]/SPAN');
for (var i=0; i<items.snapshotLength; i++) {
var item = items.snapshotItem(i);
var scores = Utils.parseInt(item.title);
item.innerHTML += ' (' + Utils.formatNumber(scores) + ')';
}
} catch (e) { Utils.log(e) }
},*/

Show: function(e) {
if (!e || !e.target || e.target.id != 'leaveAlly') return;

var list = document.getElementById('link12');
if (list.className == 'closed')
Utils.trigger(list,'click');

//this.showMemberScores();
},

Run: function()
{
document.getElementById ('eins').addEventListener ("DOMNodeInserted", function (e) { Network.Show(e); }, false);
}
}

Offline MrMage

  • Administrator
  • *****
  • Posts: 470
  • Karma: 7
Re: Dragosim & redesign
« Reply #12 on: June 29, 2010, 05:29:37 PM »
Thank you. I have decided to not update the script for now and instead recommend AntiGame with your modifications.

Offline qweras

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: Dragosim & redesign
« Reply #13 on: July 09, 2010, 07:06:40 PM »
Hey guys,
you have no idea how much I miss dragosim in redesign.
That's why I was exited to give it a try to get antigame a nice dragosim-button, but sadly, it doesn't work. I replaced the code given by aldaris in the antigame script, the websim-button changes to dragosim (yay!) and tha dragosim page opens ('nother yay!), but all the field remain empty.
I also tried to replace "french" with "german", as I play german ogame, but... well, no difference. The resulting URL is:
http://drago-sim.com/index.php?lang=germande&tech_a0_0=10&tech_a0_1=11&tech_a0_2=10&engine0_0=9&engine0_1=8&engine0_2=4&start_pos=0:0:0
...and I guess there is missing a bit.

Any idea what's wrong?

Offline MrMage

  • Administrator
  • *****
  • Posts: 470
  • Karma: 7
Re: Dragosim & redesign
« Reply #14 on: July 09, 2010, 08:36:27 PM »
Hi,

lang=germande should be lang=german, the own technologies have to be transmitted differently, and you have to attach the original spy report in the 'scan' field. I suggest you have a look at the original DragoSim Greasemonkey script (http://drago-sim.com/greasemonkey/dragosim-ogame.user.js) and the documentation (http://drago-sim.com/panel.php?name=bedienung&style=new&lang=german).

Greetings

MrMage