Last active
December 11, 2020 04:22
-
-
Save TheEmpty/63a76fdfd01958772fb9452df013df76 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name PS Direct to checkout | |
// @namespace https://myles.empty.best | |
// @version 0.1 | |
// @description Get that fucking PS5 | |
// @author Myles "Empty" Best | |
// @match https://my.account.sony.com/central/signin/* | |
// @match https://direct.playstation.com/en-us/consoles/console/playstation5-console.3005816 | |
// @match https://direct.playstation.com/en-us/checkout* | |
// @require http://code.jquery.com/jquery-3.4.1.min.js | |
// @grant none | |
// ==/UserScript== | |
/* | |
You: OMG queue pop, lemme get in queue | |
You: Captcha | |
Sony: here come in, | |
Script: are we logged in? if not, I'mma log in | |
Script: Add PS5 to cart, let's checkout | |
You: fill in CCV and press checkout | |
*/ | |
////////////////////////////////////////////////////////// | |
// CONFIGURE THIS BEFORE RUNNING OR IT WILL FUCK YOU UP // | |
////////////////////////////////////////////////////////// | |
var PS_DIRECT_USERNAME="[email protected]" | |
var PS_DIRECT_PASSWORD="yourpassword" | |
//////////////////////////////////// | |
// AND DON'T MESS WITH THIS BELOW // | |
//////////////////////////////////// | |
async function wait_for(query) { | |
while(true) { | |
var node = $(query); | |
if(node.length != 0 && node.is(":visible")) { | |
break; | |
} | |
console.log("" + query + " not available yet, waiting."); | |
await new Promise(r => setTimeout(r, 500)); | |
} | |
} | |
async function fill_in(query, value) { | |
await wait_for(query); | |
$(query).val(value); | |
$(query).focus(); | |
$(query).blur(); | |
} | |
async function press_button(query) { | |
await wait_for(query); | |
$(query).click(); | |
console.log("Button " + query + " pressed"); | |
} | |
async function login() { | |
fill_in("#ember20", PS_DIRECT_USERNAME); | |
$("#ember21").children("button").click(); | |
fill_in("#ember37", PS_DIRECT_PASSWORD); | |
$("#ember39").children("button").click(); | |
} | |
async function main() { | |
if (window.top != window.self) return; | |
await new Promise(r => setTimeout(r, 1200)); | |
if ($("a.js-topnav-desktop-signin-link:visible").length != 0) { | |
console.log("Redirecting to login"); | |
document.location = $("a.js-topnav-desktop-signin-link")[0].href; | |
} else if(document.location.host == "my.account.sony.com") { | |
login(); | |
} else if(document.location.pathname == "/en-us/checkout") { | |
$(".checkout-cta__next:visible").click(); | |
} else { | |
var node = $("producthero-info").find("[aria-label='Add to Cart']"); | |
if(node.is(":visible")) { | |
node.click(); | |
await new Promise(r => setTimeout(r, 1000)); | |
document.location = "https://direct.playstation.com/en-us/checkout?tab=cart"; | |
} | |
} | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment