Skip to content

Instantly share code, notes, and snippets.

@GarrettBlackmon
Last active March 7, 2025 02:45
Show Gist options
  • Select an option

  • Save GarrettBlackmon/dbc1bdb8a00975ad90c507a7a558fc46 to your computer and use it in GitHub Desktop.

Select an option

Save GarrettBlackmon/dbc1bdb8a00975ad90c507a7a558fc46 to your computer and use it in GitHub Desktop.
get-gpu-min.js
javascript:!function(){if(window.autoCartState||(window.autoCartState={running:!1,count:0}),window.autoCartState.running){window.autoCartState.running=!1,console.log("%c\uD83D\uDED1 Auto Add-to-Cart Stopped!","color:red;font-weight:bold;");return}window.autoCartState.running=!0,window.autoCartState.count=0,console.log("%c\uD83D\uDE80 Auto Add-to-Cart Script Loaded!","color:yellow;font-weight:bold;"),console.log("%c\uD83D\uDCA1 A popup will appear. Paste your copied fetch() request inside and click OK.","color:lightblue;"),console.log("%c\uD83D\uDED1 Click the bookmark again to stop the script.","color:orange;font-weight:bold;");let t=prompt("Paste your fetch() request here (exactly as copied from DevTools):");try{if(!t.startsWith("fetch("))throw Error("Invalid fetch() request. Make sure you copied the full request.");let e=t.match(/fetch\("([^"]+)"/)[1],o=t.match(/"headers": ({[\s\S]+?})/),a=t.match(/"body": "([^"]+)"/),r=t.match(/"method": "([^"]+)"/)[1];if(!e||!r)throw Error("Could not extract request details.");let n=o?JSON.parse(o[1]):{},l=a?a[1]:null,c=null;Object.keys(n).forEach(t=>{t.toLowerCase().startsWith("sec-")&&delete n[t]}),!function t(){if(!window.autoCartState.running){console.log("%c\uD83D\uDED1 Auto Add-to-Cart Stopped!","color:red;font-weight:bold;");return}console.clear(),window.autoCartState.count++;let o=new Date().toLocaleTimeString(),a=performance.now();console.log(`%c[${o}] 🛒 Attempt #${window.autoCartState.count}: Sending Add-to-Cart Request via XHR...`,"color:cyan;font-weight:bold;");let i=new XMLHttpRequest;for(let u in i.open(r,e,!0),n)try{i.setRequestHeader(u,n[u])}catch(d){console.warn(`⚠️ Could not set header: ${u}`)}i.onreadystatechange=function(){if(4===i.readyState){var e;let r=(performance.now()-a).toFixed(2);console.log(`%c[${o}] ✅ Request #${window.autoCartState.count} Sent (Response Time: ${r} ms)`,"color:green;font-weight:bold;");let n=i.responseText;console.log(`%c📦 Server responded!`,"color:green;font-weight:bold;"),e=n,console.log("%c\uD83D\uDD0D FULL RESPONSE DETAILS:","color:orange;font-weight:bold;"),console.table(JSON.parse(e));let l=JSON.stringify(n);if(null!==c&&c!==l){console.log("%c\uD83D\uDEA8 RESPONSE CHANGED! POSSIBLE STOCK UPDATE! \uD83D\uDD14 SOUNDING THE ALARM! SCRIPT STOPPED!","color:red;font-weight:bold;background:yellow;"),new Audio("https://www.myinstants.com/media/sounds/bell.mp3").play(),window.autoCartState.running=!1;return}c=l,setTimeout(t,2e3)}},i.send(l)}(),console.log("%c\uD83D\uDE80 Auto Add-to-Cart Running! Click the bookmark again to stop.","color:yellow;font-weight:bold;")}catch(i){console.error("%c❌ ERROR: Invalid fetch() request pasted! Please try again.","color:red;font-weight:bold;"),window.autoCartState.running=!1}}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment