Advertisement
Guest User

Untitled

a guest
Aug 18th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. var startedprocess = 0;
  2. var imgurl = 'https://cdn.shopify.com/s/files/1/0014/2678/4313/products/img36_1.jpg?v=1534529438'; // IMG URL HERE
  3. var attribute = '11' // ENTER THE SIZE OF THE PRODUCT HERE HENCE ATTRIBUTE
  4. var executiontime = [20,00,00]; // TIME OF EXECUTION (24 HOUR FORMAT SO 8PM >> 20) [HOURS,MINUTES,SECONDS]
  5. var maxcycles = 10; // HOW MANY TIMES WOULD YOU LIKE THE SCRIPT TO RUN
  6.  
  7.  
  8. function gtime(){
  9. var now = new Date();
  10. var pretty = [
  11. now.getHours(),
  12. ':',
  13. now.getMinutes(),
  14. ':',
  15. now.getSeconds()
  16. ].join('');
  17. return pretty;
  18. }
  19.  
  20. function getProducts(callback){
  21. jQuery.ajax({
  22. type:"GET",
  23. url:"https://retailsat.com/products.json?limit=250"
  24. }).done(function(r){
  25. var output = [];
  26. r.products.forEach(function(product){
  27. if(product.title.indexOf('Process Fee') == -1){
  28. output.push(product);
  29. }
  30. })
  31. callback(output);
  32. })
  33. }
  34.  
  35. var iteration = 0;
  36. function mrequest(){
  37. console.log("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
  38. if(iteration <= maxcycles){
  39. var intercept = 0;
  40. iteration = iteration + 1;
  41. console.log('STARTING ITERATION #' + iteration);
  42. var productid = '';
  43. getProducts(function(products){
  44. products.every(function(product){
  45. if(productid !== ''){return false}
  46. product.images.every(function(img){
  47. if(productid !== ''){return false}
  48. if(img.src == imgurl){
  49. product.variants.every(function(variant){
  50. if(productid !== ''){return false}
  51. if(variant.title.indexOf(attribute) > -1 || variant.public_title.indexOf(attribute) > -1){
  52. if(true){
  53. console.log('[INSTANCE #' + iteration + '] FOUND ITEM!');
  54. productid = variant.id;
  55. return false;
  56. } else {console.log('[INSTANCE #' + iteration + '] FOUND THE ITEM BUT ITS NOT AVAILABLE TO BUY YET.');intercept = 1;return false;}
  57. } else { return true; }
  58. })
  59. }
  60. return true;
  61. })
  62. return true;
  63. })
  64.  
  65. if(intercept == 1){console.log('-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-');setTimeout(function(){mrequest();}, 750); return false;}
  66. if(productid == ''){
  67. console.log('[INSTANCE #' + iteration + '] COULD NOT FIND ITEM IN ANY COLLECTION RESTARTING.');
  68. console.log('-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-');
  69. setTimeout(function(){mrequest();}, 500);
  70. } else {
  71. console.log('[INSTANCE #' + iteration + '] Adding to Cart....');
  72.  
  73. jQuery.ajax({
  74. type:"POST",
  75. url:"https://retailsat.com/cart/add.js",
  76. data:{form_type:"product",utf8:"%E2%9C%93",id:productid,quantity:1},
  77. callback: function(r){console.log('SUCCESS!');window.location.href = 'https://retailsat.com/checkout';}
  78. }).fail(function(){
  79. console.log('SUCCESS!');window.location.href = 'https://retailsat.com/checkout';
  80. }).done(function(){console.log('SUCCESS!');window.location.href = 'https://retailsat.com/checkout';})
  81.  
  82. }
  83. })
  84. }
  85. }
  86.  
  87.  
  88. setInterval(function(){
  89. var time = gtime().split(':');
  90. if(+time[0] == executiontime[0] && (+time[1] == executiontime[1] || +time[1] > executiontime[1]) && (+time[2] == executiontime[2] || +time[2] > executiontime[2]) && startedprocess == 0){
  91. startedprocess = 1;
  92. console.log('Starting Process...');
  93. mrequest();
  94. document.title = 'SCRIPT STARTED';
  95. }
  96. }, 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement