Last active
April 8, 2021 16:12
-
-
Save AkdM/5d18ed9d720948ca213bbf19ee6f432b to your computer and use it in GitHub Desktop.
Add to Bookmark
This file contains 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
javascript: (async function () { | |
const t = (t) => (document.querySelector(".page-title").innerText = t); | |
try { | |
t("looking for product id..."); | |
var e = (() => document.location.pathname.split("/").filter((t) => /\d{10}/.test(t))[0])(); | |
t("adding to cart..."), await ((t) => fetch(`https://www.amd.com/en/direct-buy/add-to-cart/${t}`, { credentials: "include", method: "GET", mode: "cors", redirect: "error" }))(e), t("added to cart, fetching checkout URL..."); | |
var a = await (async () => { | |
var t = await fetch("https://www.amd.com/en/direct-buy/shopping-cart/modal?_wrapper_format=drupal_modal", { credentials: "include", method: "POST", mode: "cors" }); | |
return (await t.text()).match(/\/.{2}\\\/direct-buy\\\/checkout\\\/payment\\\/\d*\\\/.{2}/)[0].replace(/\\/g, ""); | |
})(); | |
t("redirecting to checkout..."), ((t) => (window.location = t))(a); | |
} catch (e) { | |
t(`something went wrong, try again! .... ${e.message} @ ${e.stack}`); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment