Created
September 21, 2012 14:06
-
-
Save paradoxxxzero/3761652 to your computer and use it in GitHub Desktop.
Greclaim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var _rc_ = {}; | |
| $('#memo_icon').remove(); | |
| $('<a>').attr('id', '_rc_claim').addClass('town_control').css({left: '322px', backgroundPosition: "-323px 9px"}).text('+').on('click', _rc_start).insertBefore($('#city_overview')); | |
| function _rc_start () { | |
| if(!_rc_.hasOwnProperty(Game.townId)) { | |
| $('#_rc_claim').text('-').off('click', _rc_start).on('click', _rc_stop); | |
| var farms = $('.farmtown_owned a').map(function () { return JSON.parse(atob($(this).attr('href')).split(String.fromCharCode(0))[0]).id;}); | |
| _rc_[Game.townId] = farms; | |
| console && console.log('Starting for town', Game.townId, 'with farms', farms); | |
| farms.each(function (i, e) { | |
| $('#farm_town_flag_' + e).css({backgroundColor: 'orangered'}); | |
| }); | |
| _rc_claim(Game.townId, farms.get()); | |
| } | |
| } | |
| function _rc_stop () { | |
| if(_rc_.hasOwnProperty(Game.townId)) { | |
| $('#_rc_claim').text('+').off('click', _rc_stop).on('click', _rc_start); | |
| _rc_[Game.townId].each(function (i, e) { | |
| $('#farm_town_flag_' + e).css({backgroundColor: 'purple'}); | |
| }); | |
| delete _rc_[Game.townId]; | |
| } | |
| } | |
| function _rc_claim(town_id, farms_queue) { | |
| var farm = farms_queue.shift(); | |
| $('#farm_town_flag_' + farm).css({backgroundColor: 'black'}); | |
| $.ajax({ | |
| url: 'http://fr38.grepolis.com/game/farm_town_info?action=claim_load&town_id=' + town_id + '&h=' + Game.csrfToken, | |
| type: 'POST', | |
| data: { | |
| json: '{"target_id":"' + farm + '","claim_type":"normal","time":300,"town_id":' + town_id + ',"nlreq_id":0}' | |
| } | |
| }).done(function () { | |
| $('#farm_town_flag_' + farm).css({backgroundColor: 'blue'}); | |
| if (farms_queue.length > 0) { | |
| setTimeout(function() { | |
| _rc_claim(town_id, farms_queue); | |
| }, parseInt(1000 * 10 * Math.random())); | |
| } else { | |
| var delay = 1000 * 60 * 5.2 + parseInt(1000 * 13 * Math.random()), | |
| next = new Date((new Date().getTime() + delay)).toLocaleTimeString(); | |
| console && console.log('Next: ' + next); | |
| setTimeout(function() { | |
| if(_rc_.hasOwnProperty(Game.townId)) { | |
| _rc_claim(town_id, _rc_[town_id].get()); | |
| } else { | |
| console && console.log('Aborted'); | |
| } | |
| }, delay); | |
| } | |
| }).fail(function () { | |
| $('#farm_town_flag_' + farm).css({backgroundColor: 'pink'}); | |
| }); | |
| } | |
| $('#prev_city, #next_city').on('click', function () { | |
| setTimeout(function () { | |
| WMap.mapJump({'id': +Game.townId,'ix': WMap.islandPosition.x,'iy': WMap.islandPosition.y}, true); | |
| if(_rc_.hasOwnProperty(Game.townId)) { | |
| $('#_rc_claim').text('-').off('click', _rc_start).on('click', _rc_stop); | |
| } else { | |
| $('#_rc_claim').text('+').off('click', _rc_stop).on('click', _rc_start); | |
| } | |
| }, 50); | |
| }); |
Author
can you please explain what this script do?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bookmarklet: