Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1.  
  2. // ==UserScript==
  3. // @author pracka
  4. // @name Deamonicus
  5. // @namespace Erep
  6. // @description Automatically starts
  7. // @version 0.2
  8. // @include http://www.erepublik.com/*
  9. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
  10. // ==/UserScript==
  11.  
  12. if (0==$('ul.resistance_war').length) {
  13. location.href = "http://www.erepublik.com/en";
  14. }
  15.  
  16. var ResistanceForceInsert = function($, window, undefined) {
  17. function rwHelper() {
  18. if(!alreadyFunder && !$(this).hasClass('disabled')){
  19. $.post('/en/military/rw-support', {type : 'fund', _token: SERVER_DATA.csrfToken}, function(response){
  20. if(!response.error){
  21. alreadySupporter = true;
  22. alreadyFunder = true;
  23. if(SERVER_DATA.funders_count + 1 == 10){
  24. $("div.fighters_needed p").html("The resistance war will start any minute now!");
  25. }
  26. financeIt();
  27. if(SERVER_DATA.is_citizen){
  28. var ca;
  29. ca = $('.citizenship_currency_amount strong');
  30. var currency_ammount = parseInt(ca.html())
  31. ca.html(currency_ammount - 1000);
  32. }
  33. $('#funders_count_small').text(SERVER_DATA.funders_count + 1);
  34. $('#funders_count').text(10 - SERVER_DATA.funders_count - 1);
  35. $("#fundRW_btn").addClass('disabled')
  36. .attr("title", SERVER_DATA.messages["already_funder"])
  37. .tipsy({gravity: 's'});
  38. $("#supportRW_btn").addClass('disabled')
  39. .attr("title", SERVER_DATA.messages['confirm_supporter'])
  40. .tipsy({gravity: 's'});
  41. }else{
  42. if(response.message == "ALREADY_FUNDED"){
  43. alreadySupporter = true;
  44. alreadyFunder = true;
  45. $("#fundRW_btn").addClass('disabled')
  46. .attr("title", SERVER_DATA.messages["already_funder"])
  47. .tipsy({gravity: 's'});
  48. $("#supportRW_btn").addClass('disabled')
  49. .attr("title", SERVER_DATA.messages['confirm_supporter'])
  50. .tipsy({gravity: 's'});
  51. }else if(response.message == "RECENTLY_CONQUERED"){
  52. rwError(SERVER_DATA.messages['err_too_early']+response.time);
  53. }else if(response.message == "ONGOING_RW_CAMPAIGN"){
  54. rwError(SERVER_DATA.messages['err_ongoing_rw']+response.region);
  55. }else if(response.message == "ONGOING_CAMPAIGN"){
  56. rwError(SERVER_DATA.messages['err_ongoing']);
  57. }else if(response.message == "INSUFFICIENT_FUNDS"){
  58. rwError(SERVER_DATA.messages['err_funds']);
  59. }
  60. }
  61. }, 'json');
  62. }else{
  63. rwError(SERVER_DATA.messages['already_funder']);
  64. }
  65. };
  66. $(document).ready(function () {
  67. if (location.href == 'http://www.erepublik.com/en') {
  68. if ($('#fundRW_btn').length > 0) {
  69. rwHelper();
  70. } else {
  71. // autoRefresh
  72. }
  73. }
  74. });
  75. };
  76. // Script Insert
  77. var script = document.createElement('script');
  78. script.textContent = '(' + ResistanceForceInsert + ')(jQuery, window);';
  79. document.body.appendChild(script);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement