Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. var realmail = 'emailsin@';
  2.  
  3. function telepizza(email, callback) {
  4. var data = {
  5. email: email
  6. }
  7. var url = 'https://d6ow8diqzony0.cloudfront.net/check-prize';
  8. $.ajax({
  9. type: "POST",
  10. url: url,
  11. dataType: 'json',
  12. contentType: "application/json",
  13. crossDomain: true,
  14. data: JSON.stringify(data),
  15. success: function (result) {
  16. console.log(result);
  17. var body = JSON.stringify(JSON.parse(result['body']));
  18. var response = JSON.parse(body);
  19. switch (response.responseMessage) {
  20. case 'USER_IS_WINNER':
  21. callback(true);
  22. break;
  23. case 'USER_NOT_WIN':
  24. callback(false);
  25. break;
  26. default:
  27. console.log("¡UpsLoimos este email no es valido, está repetido o ha sido mal introducido.¡INTENTALO DE NUEVO!");
  28. callback(false)
  29. break;
  30. }
  31. },
  32. error: function (e) {
  33. console.log("ERRORssage");
  34. }
  35. });
  36. }
  37. function validateMail(email, callback) {
  38. console.log('######################');
  39. var data = {
  40. email: email,
  41. receive_offert: true
  42. }
  43. console.log(data);
  44. var url = 'https://d6ow8diqzony0.cloudfront.net/check-mail';
  45. $.ajax({
  46. type: "POST",
  47. url: url,
  48. dataType: 'json',
  49. contentType: "application/json",
  50. crossDomain: true,
  51. data: JSON.stringify(data),
  52. success: function (result) {
  53. var body = JSON.stringify(JSON.parse(result['body']));
  54. var response = JSON.parse(body);
  55. switch (response.responseMessage) {
  56. case 'EMAIL_SAVED':
  57. break;
  58. case 'DYNAMO_ERR':
  59. console.log("¡UpsHaridorror interno, por favor, vuelve a intentarlo.");
  60. break;
  61. case 'USER_HAS_PARTICIPED':
  62. console.log("¡UpsElrioa participado en el concurso.");
  63. break;
  64. case 'FORBIDDEN':
  65. console.log("¡UpsEstaanzado el número máximo de peticiones. Por favor, vuelve a intentarlo transcurridos 30 minutos.");
  66. break;
  67. default:
  68. console.log("¡UpsLoimos este email no es valido, está vacío, está repetido o ha sido mal introducido.¡INTENTALO DE NUEVO!");
  69. break;
  70. }
  71. callback(response.responseMessage)
  72. },
  73. error: function (e) {
  74. console.log("ERRORssage");
  75. }
  76. });
  77. }
  78. var nombremail = realmail;
  79. var intents_tramp = 0;
  80. function execute() {
  81. var mail = nombremail + intents_tramp + '@gmail.com';
  82. validateMail(mail, function (response) {
  83. console.log(intents_tramp++);
  84. if (response == 'EMAIL_SAVED') {
  85. telepizza(mail, function(winner) {
  86. if(winner) {
  87. alert('GANADOR !!! PIZZA GRATIS');
  88. } else {
  89. repeat();
  90. }
  91. });
  92. } else {
  93. repeat();
  94. }
  95. });
  96. }
  97. function repeat() {
  98. mail = nombremail + intents_tramp + '@gmail.com';
  99. setTimeout(function () {
  100. execute();
  101. }, 4000);
  102. }
  103. execute();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement