Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- javascript:!async function(){var t=[],e=function(e){t.push(e)},a=function(a){e(a),alert(t.join("\n"))},r=location.pathname.match(/-(\d{6,})\/?$/),n=r?r[1]:null;if(n){var i=function(t){var e=Number(t),a=[[800,999,"NT"],[2600,2618,"ACT"],[2900,2920,"ACT"],[1e3,2999,"NSW"],[3e3,3999,"VIC"],[4e3,4999,"QLD"],[5e3,5999,"SA"],[6e3,6999,"WA"],[7e3,7999,"TAS"],[8e3,8999,"VIC"],[9e3,9999,"QLD"]].find(function(t){return e>=t[0]&&e<=t[1]});return a?a[2]:"NSW"},o=async function(t,e,a){var r=await fetch("https://api.kmart.com.au/gateway/graphql",{method:"POST",credentials:"include",headers:{"content-type":"application/json",accept:"*/*"},body:JSON.stringify({operationName:t,query:e,variables:a||{}})}),n=await r.json();if(n.errors)throw new Error(t+" rejected: "+n.errors.map(function(t){return t.message}).join(" / "));return n.data},c='id version postcodeSelector { postalCode state city country } totalPrice { centAmount } lineItems { name(locale: "en") quantity variant { sku attributes { name value } } }',s=async function(){try{var t=await o("getMyActiveCart","query getMyActiveCart { me { activeCart { "+c+" } } }");return t.me&&t.me.activeCart||null}catch(t){return e("Couldn't read your cart. Delete all cart contents and try again"),null}},u=function(t){return(t&&t.lineItems||[]).filter(function(t){return t.variant.sku===n}).reduce(function(t,e){return t+e.quantity},0)},d=function(t){var e=(t&&t.lineItems||[]).find(function(t){return t.variant.sku===n}),a=e&&e.variant.attributes.find(function(t){return"ItemLimit"===t.name});return a?Number(a.value):null},l=function(t,e,a){var r=[{addLineItem:{sku:n,quantity:1}}].concat(a||[]);return o("updateMyBag","mutation updateMyBag($id: String!, $version: Long!, $actions: [MyCartUpdateAction!]!) { updateMyCart(id: $id, version: $version, actions: $actions) { "+c+" } }",{id:t,version:e,actions:r}).then(function(t){return t.updateMyCart})},y=await s(),p=!!y,m=y&&y.postcodeSelector;if(!m||!m.postalCode){var f=prompt("What postcode should this order ship to?");if(!f||!/^\d{4}$/.test(f))return void alert("That does not look like a 4-digit postcode, so stopping here.");m={postalCode:f,state:i(f),city:"",country:"AU"}}e("Shipping to "+m.postalCode+" "+(m.state||"")+".");var v=d(y),h=u(y);if(null!==v&&(e("In your cart: "+h+". Maximum allowed: "+v),h>=v))a("You are already sitting at the cap of "+v+", so not adding another - that would just fail at checkout.");else{var g;if(!y)y=(await o("createMyBag","mutation createMyBag($draft: MyCartDraft!) { createMyCart(draft: $draft) { id version } }",{draft:{currency:"AUD",country:"AU",shippingAddress:{country:"AU"},postcodeSelector:JSON.stringify({city:m.city||"",postalCode:m.postalCode,state:m.state||i(m.postalCode),country:"AU"}),selectedCncStoreId:"delivery"}})).createMyCart,e("Created a new shopping cart.");try{var C=p?[]:[{setCustomField:{name:"selectedCncStoreId",value:"delivery"}}];g=await l(y.id,y.version,C)}catch(t){e("The add attempt came back with an error: "+t.message);var w=await s();if(w&&u(w)>h)e("Despite the error, it still worked."),g=w;else{if(!w)return void alert("Could not add this item - "+t.message);e("Trying again"),g=await l(w.id,w.version,[])}}var A=u(g),S=d(g);e("All set - your cart now shows "+A+" of this item"+(S?" (cap is "+S+")":"")+"."),S&&A>S&&e("you're over the maximum limit"),a("Give the page a refresh to see the updated cart icon.")}}else alert("That didn't work. Quick-checkout instructions for kmart.com.au:\n1) Log out, delete all items in your cart. Alternatively, use an incognito window.\n2) Add a random available product, and proceed to the very last payment step. ('Check out securely')\n3) Open a separate tab. Navigate to the product page of something you want to add to your cart, which is 'coming soon' but doesn't have an add to cart button yet.\n4) Press this special add to cart button. Refresh the page and remove unwanted products.\n5) Change back to the original tab.\n6) When the product is available to order, complete your payment.\n\n\nNote that these instructions are provided to give all collectors a fair go. The big scalper communities have this tool, and therefore so should all collectors.\n\n")}();
Advertisement
Add Comment
Please, Sign In to add comment