Created
September 21, 2012 14:06
-
-
Save paradoxxxzero/3761652 to your computer and use it in GitHub Desktop.
Revisions
-
paradoxxxzero revised this gist
Oct 29, 2012 . 1 changed file with 8 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -121,14 +121,18 @@ NotificationLoader.recvNotifyData = function (retdata, game_initialization) { var popup = webkitNotifications.createNotification('http://cdn.grepolis.com/images/game/start/favicon.ico', 'Grepolis - ' + title, message); popup.show(); console && console.log(notif.type, ' -> ', notif.subject, __ = $.extend({}, notif)); function cancel(pop) { setTimeout(function(){ console && console.log('Cancelling', pop); pop.cancel(); }, 15000); } cancel(popup); } } } } } } catch(e) {} old_notif(retdata, game_initialization); }; -
paradoxxxzero revised this gist
Oct 20, 2012 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -108,7 +108,7 @@ NotificationLoader.recvNotifyData = function (retdata, game_initialization) { title = notif_label[notif.type], message = ''; if(notif.subject) { message = $('<i>' + notif.subject +'</i>').text(); } else if (notif.type == 'building_finished') { try { var param = JSON.parse(notif.param_str); @@ -118,7 +118,8 @@ NotificationLoader.recvNotifyData = function (retdata, game_initialization) { } } if(notif.type != 'systemmessage') { var popup = webkitNotifications.createNotification('http://cdn.grepolis.com/images/game/start/favicon.ico', 'Grepolis - ' + title, message); popup.show(); console && console.log(notif.type, ' -> ', notif.subject, __ = $.extend({}, notif)); setTimeout(function(){ popup.cancel(); @@ -130,4 +131,4 @@ NotificationLoader.recvNotifyData = function (retdata, game_initialization) { } } catch(e) {} old_notif(retdata, game_initialization); }; -
paradoxxxzero revised this gist
Oct 19, 2012 . 1 changed file with 9 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -61,9 +61,11 @@ function _rc_claim(town_id, farms_queue) { } // Auto jump $('#prev_city, #next_city').on('click', function (e) { setTimeout(function () { if (!e.shiftKey) { 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 { @@ -106,7 +108,7 @@ NotificationLoader.recvNotifyData = function (retdata, game_initialization) { title = notif_label[notif.type], message = ''; if(notif.subject) { message = notif.subject; } else if (notif.type == 'building_finished') { try { var param = JSON.parse(notif.param_str); @@ -116,8 +118,11 @@ NotificationLoader.recvNotifyData = function (retdata, game_initialization) { } } if(notif.type != 'systemmessage') { var popup = webkitNotifications.createHTMLNotification('http://cdn.grepolis.com/images/game/start/favicon.ico', 'Grepolis - ' + title, message).show(); console && console.log(notif.type, ' -> ', notif.subject, __ = $.extend({}, notif)); setTimeout(function(){ popup.cancel(); }, 15000); } } } -
paradoxxxzero revised this gist
Oct 17, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ function _rc_start () { if(!_rc_.hasOwnProperty(Game.townId)) { $('#_rc_claim').text('-').off('click', _rc_start).on('click', _rc_stop); var farms = $('.farmtown_owned_on_same_island 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) { -
paradoxxxzero revised this gist
Oct 10, 2012 . 1 changed file with 24 additions and 13 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -97,21 +97,32 @@ var notif_label = { var old_notif = NotificationLoader.recvNotifyData; NotificationLoader.recvNotifyData = function (retdata, game_initialization) { try { if (!game_initialization) { if (webkitNotifications && webkitNotifications.checkPermission() == 0) { if (retdata.notifications.length) { for (var i = 0; i < retdata.notifications.length; i++) { var notif = retdata.notifications[i], title = notif_label[notif.type], message = ''; if(notif.subject) { message = $('<i>' + notif.subject +'</i>').text(); } else if (notif.type == 'building_finished') { try { var param = JSON.parse(notif.param_str); message = param.building_name + ' at level ' + param.new_level + ' on ' + param.town_name; } catch(e) { message = 'Error in param_string'; } } if(notif.type != 'systemmessage') { webkitNotifications.createNotification('http://cdn.grepolis.com/images/game/start/favicon.ico', 'Grepolis - ' + title, message).show(); console && console.log(notif.type, ' -> ', notif.subject, __ = $.extend({}, notif)); } } } } } } catch(e) {} old_notif(retdata, game_initialization); }; -
paradoxxxzero revised this gist
Oct 8, 2012 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -104,11 +104,14 @@ NotificationLoader.recvNotifyData = function (retdata, game_initialization) { for (var i = 0; i < retdata.notifications.length; i++) { var notif = retdata.notifications[i], title = notif_label[notif.type]; if(notif.type != 'systemmessage') { webkitNotifications.createNotification('http://cdn.grepolis.com/images/game/start/favicon.ico', 'Grepolis - ' + title, $('<i>' + notif.subject +'</i>').text()).show(); console && console.log(notif.type, ' -> ', notif.subject); } } } } } } catch(e) {} old_notif(retdata, game_initialization); }; -
paradoxxxzero revised this gist
Oct 5, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -104,7 +104,7 @@ NotificationLoader.recvNotifyData = function (retdata, game_initialization) { for (var i = 0; i < retdata.notifications.length; i++) { var notif = retdata.notifications[i], title = notif_label[notif.type]; webkitNotifications.createNotification('http://cdn.grepolis.com/images/game/start/favicon.ico', 'Grepolis - ' + title, $('<i>' + notif.subject +'</i>').text()).show(); } } } -
paradoxxxzero revised this gist
Oct 5, 2012 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -97,16 +97,18 @@ var notif_label = { var old_notif = NotificationLoader.recvNotifyData; NotificationLoader.recvNotifyData = function (retdata, game_initialization) { try { if (!game_initialization) { if (webkitNotifications && webkitNotifications.checkPermission() == 0) { if (retdata.notifications.length) { for (var i = 0; i < retdata.notifications.length; i++) { var notif = retdata.notifications[i], title = notif_label[notif.type]; webkitNotifications.createNotification('http://cdn.grepolis.com/images/game/start/favicon.ico', 'Grepolis - ' + title, $('<i>' + null +'</i>').text()).show(); } } } } } catch(e) {} old_notif(retdata, game_initialization); }; -
paradoxxxzero revised this gist
Oct 4, 2012 . 1 changed file with 45 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,6 +3,10 @@ $('#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 (webkitNotifications && webkitNotifications.checkPermission() != 0) { webkitNotifications.requestPermission(); } 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;}); @@ -28,7 +32,7 @@ function _rc_claim(town_id, farms_queue) { var farm = farms_queue.shift(); $('#farm_town_flag_' + farm).css({backgroundColor: 'black'}); $.ajax({ url: location.origin + '/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}' @@ -56,6 +60,7 @@ function _rc_claim(town_id, farms_queue) { }); } // Auto jump $('#prev_city, #next_city').on('click', function () { setTimeout(function () { WMap.mapJump({'id': +Game.townId,'ix': WMap.islandPosition.x,'iy': WMap.islandPosition.y}, true); @@ -66,3 +71,42 @@ $('#prev_city, #next_city').on('click', function () { } }, 50); }); // Desktop notification var notif_label = { alliance_invitation: 'Alliance Invitation', all_building_finished: 'All Buildings Finished', awmessage: 'Message', backbone: 'Backbone', building_finished: 'Building Finished', incoming_attack: 'Incoming Attack!', incoming_support: 'Incoming Support', mass_notification: 'Mass Notification', newalliancepost: 'New Alliance Post', newaward: 'New Award', newmessage: 'New Message', newreport: 'New Report', newtempreport: 'New Temp Report', notassigned: 'Not Assigned', phoenician_salesman_arrived: 'Phoenician Salesman Arrived', planed_attack: 'Planed Attack', resourcetransport: 'Resource Transport', show_captcha: 'Show Captcha', systemmessage: 'System Message' }; var old_notif = NotificationLoader.recvNotifyData; NotificationLoader.recvNotifyData = function (retdata, game_initialization) { if (!game_initialization) { if (webkitNotifications && webkitNotifications.checkPermission() == 0) { if (retdata.notifications.length) { for (var i = 0; i < retdata.notifications.length; i++) { var notif = retdata.notifications[i], title = notif_label[notif.type]; webkitNotifications.createNotification('http://cdn.grepolis.com/images/game/start/favicon.ico', 'Grepolis - ' + title, $(notif.subject).text()).show(); } } } } old_notif(retdata, game_initialization); }; -
paradoxxxzero revised this gist
Oct 3, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -58,7 +58,7 @@ function _rc_claim(town_id, farms_queue) { $('#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 { -
paradoxxxzero revised this gist
Oct 2, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ 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)) { -
paradoxxxzero revised this gist
Oct 2, 2012 . 1 changed file with 48 additions and 16 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,36 +1,68 @@ var _rc_ = {}; $('#memo_icon').remove(); $('<a>').attr('id', '_rc_claim').addClass('town_control').css({left: '322px', backgroundPosition: "-323px 9px"}).text('+').on('click', _rc_start).insertAfter($('#next_city')); 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}); 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); }); -
paradoxxxzero created this gist
Sep 21, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ var _rc_farms = $('.farmtown_owned a').map(function () { return JSON.parse(atob($(this).attr('href')).split(String.fromCharCode(0))[0]).id;}), _rc_town = $('.ftr_undefined').attr('id').split('_')[2], _rc_token = game_definition_object.csrfToken, _rc_link = $('<a>'); $('#links').append($('<li>').append(_rc_link)); function claim(farms_queue) { var farm = farms_queue.shift(); $.ajax({ url: 'http://fr38.grepolis.com/game/farm_town_info?action=claim_load&town_id=' + _rc_town + '&h=' + _rc_token, type: 'POST', data: { json: '{"target_id":"' + farm + '","claim_type":"normal","time":300,"town_id":' + _rc_town + ',"nlreq_id":0}' } }).done(function () { if (farms_queue.length > 0) { _rc_link.text(_rc_link.text() + '.'); setTimeout(function() { claim(farms_queue); }, parseInt(1000 * 10 * Math.random())); } else { var delay = 1000 * 60 * 5.1 + parseInt(1000 * 30 * Math.random()), next = new Date((new Date().getTime() + delay)).toLocaleTimeString(); _rc_link.text(' Ok! Next: ' + next); setTimeout(function() { _rc_link.text(''); claim(_rc_farms.get()); }, delay); } }).fail(function () { _rc_link.text('Error'); }); } claim(_rc_farms.get());