Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var startedprocess = 0;
- var imgurl = 'https://cdn.shopify.com/s/files/1/0014/2678/4313/products/img36_1.jpg?v=1534529438'; // IMG URL HERE
- var attribute = '11' // ENTER THE SIZE OF THE PRODUCT HERE HENCE ATTRIBUTE
- var executiontime = [20,00,00]; // TIME OF EXECUTION (24 HOUR FORMAT SO 8PM >> 20) [HOURS,MINUTES,SECONDS]
- var maxcycles = 10; // HOW MANY TIMES WOULD YOU LIKE THE SCRIPT TO RUN
- function gtime(){
- var now = new Date();
- var pretty = [
- now.getHours(),
- ':',
- now.getMinutes(),
- ':',
- now.getSeconds()
- ].join('');
- return pretty;
- }
- function getProducts(callback){
- jQuery.ajax({
- type:"GET",
- url:"https://retailsat.com/products.json?limit=250"
- }).done(function(r){
- var output = [];
- r.products.forEach(function(product){
- if(product.title.indexOf('Process Fee') == -1){
- output.push(product);
- }
- })
- callback(output);
- })
- }
- var iteration = 0;
- function mrequest(){
- 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");
- if(iteration <= maxcycles){
- var intercept = 0;
- iteration = iteration + 1;
- console.log('STARTING ITERATION #' + iteration);
- var productid = '';
- getProducts(function(products){
- products.every(function(product){
- if(productid !== ''){return false}
- product.images.every(function(img){
- if(productid !== ''){return false}
- if(img.src == imgurl){
- product.variants.every(function(variant){
- if(productid !== ''){return false}
- if(variant.title.indexOf(attribute) > -1 || variant.public_title.indexOf(attribute) > -1){
- if(true){
- console.log('[INSTANCE #' + iteration + '] FOUND ITEM!');
- productid = variant.id;
- return false;
- } else {console.log('[INSTANCE #' + iteration + '] FOUND THE ITEM BUT ITS NOT AVAILABLE TO BUY YET.');intercept = 1;return false;}
- } else { return true; }
- })
- }
- return true;
- })
- return true;
- })
- if(intercept == 1){console.log('-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-');setTimeout(function(){mrequest();}, 750); return false;}
- if(productid == ''){
- console.log('[INSTANCE #' + iteration + '] COULD NOT FIND ITEM IN ANY COLLECTION RESTARTING.');
- console.log('-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-');
- setTimeout(function(){mrequest();}, 500);
- } else {
- console.log('[INSTANCE #' + iteration + '] Adding to Cart....');
- jQuery.ajax({
- type:"POST",
- url:"https://retailsat.com/cart/add.js",
- data:{form_type:"product",utf8:"%E2%9C%93",id:productid,quantity:1},
- callback: function(r){console.log('SUCCESS!');window.location.href = 'https://retailsat.com/checkout';}
- }).fail(function(){
- console.log('SUCCESS!');window.location.href = 'https://retailsat.com/checkout';
- }).done(function(){console.log('SUCCESS!');window.location.href = 'https://retailsat.com/checkout';})
- }
- })
- }
- }
- setInterval(function(){
- var time = gtime().split(':');
- if(+time[0] == executiontime[0] && (+time[1] == executiontime[1] || +time[1] > executiontime[1]) && (+time[2] == executiontime[2] || +time[2] > executiontime[2]) && startedprocess == 0){
- startedprocess = 1;
- console.log('Starting Process...');
- mrequest();
- document.title = 'SCRIPT STARTED';
- }
- }, 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement