I strongly recommend the Firebug addon for scripting - you won't be able to use any of the greasemonkey-specific functions but it allows easy testing / script creation :)
> Battle on Fight at [0:0:0] > Result | Attacker wins (100%) | after ~ 1 rounds > Debris Field 103.500 Metal (230%), 79.500 Crystal (530%) ~ 10 Recycler > Moonchance Chance that a moon arises is 1% > Losses Attacker 45.000 Metal, 15.000 Crystal and 0 Deuterium > Losses Defender 300.000 Metal, 250.000 Crystal and 75.000 Deuterium > Theoretic Plunder 0 Metal, 0 Crystal and 0 Deuterium ~ 0 Large Cargo > Real Plunder 0 Metal, 0 Crystal and 0 Deuterium (100% Booty) > Needed Fuel 0 Deuterium > Flight times 00:00:00 h > > The user script I'm looking for would do two simple things. Calculate > profit, and convert that profit based on the relative value of each > resource. Like this: > > Metal Profit = Debris Field Metal + Real Plunder Metal - Losses > Attacker Metal I shan't write the whole script for you but will give you a decent head-start :) NB: This (using regular expressions to grab page text) isn't necessarily the "best" / "most correct" technique but its quick and usually works if the page isn't changing often :P The below JavaScript sample contains enough comments to follow what is happening on each line. If there's anything you want clarifying just shout, but remember this isn't a JavaScript school or scriptwrighting service so replies may not be timely / existant ;) . Extending it to handle other parts too should simply be a case of copy-pasting all but the 'var resultsText' line and substituting 'Debris Field' for 'Losses Attacker' / 'Losses Defender' etc and the variable name(s) to include something more relevant than 'debris' where appropriate :) I shall leave that part and how to add it to the page for you to research - I suggest that https://developer.mozilla.org/en/DOM/document.createElement is probably a good place to start :) Important note: I should probably upload this to pastebin / as a Github gist because even though it is currently formatted correctly on my screen at the moment, the regex line is rather long as is very likely to wrap somewhere between sending and appearing on your screen... but I'm feeling lazy ;) /** /Start code sample/ **/ // Grab the text within the results table var resultsText = document.getElementById('result_table').textContent; // Grab the different parts of the debris results using a 'regular expression' // nb: ([0-9]+\.?[0-9]{0,10}) effectively means any number upto // ten decimal places; The round brackets mean that whatever matches // the inside of these will be available as part of the matching array // .* means any number of any character var debris = resultsText.match(/Debris Field.*([0-9]+\.?[0-9]{0,10}) Metal.*([0-9]+\.?[0-9]{0,10}) Crystal.*([0-9]+\.?[0-9]{0,10}) Recycler/i); //nb: the above line may wrap.. it should all be on one line only // This just logs the contents of the debris variable to the Firebug or // Firefox 4+ 'web console' console.info(debris) // The following simply maps the different parts of the 'debris' array // to more readable variable names var debris_metal = debris[1]; var debris_crystal = debris[2]; var debris_recycler = debris[3]; /** /End code sample/ **/ -- You received this message because you are subscribed to the Google Groups "greasemonkey-users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en.
