-
-
Save PartAlert/a9e8bb6f3b6709ba3a56665164f03978 to your computer and use it in GitHub Desktop.
License: The MIT License
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
(async () => { | |
const urlMatch = location.href.match(/^https:\/\/www.amd.com\/.{2}\/direct-buy\/(\d{10})?/); | |
if (urlMatch == null) { | |
const err = 'You must run this script from www.AMD.com.\nThe script will make the add to cart button appear.'; | |
alert(err); | |
throw new Error(err); | |
} | |
const pid = urlMatch[1]; | |
const products = document.querySelectorAll('.view-shop-product-search .views-row'); | |
products.forEach(p => { | |
const idMatch = p.querySelector('.shop-full-specs-link a').getAttribute('href').match(/\d{10}/); | |
if (idMatch == null) return; | |
if (p.querySelector('.shop-links button') != null) return; | |
p.querySelector('.shop-links').insertAdjacentHTML('beforeend', `<button class="btn-shopping-cart btn-shopping-neutral use-ajax" data-progress-type="fullscreen" href="/en/direct-buy/add-to-cart/${idMatch[0]}">PA | Add To Cart</button>`) | |
}); | |
const details = document.querySelector('#product-details-info .product-page-description'); | |
if (details && pid && !details.querySelector('button')) { | |
details.insertAdjacentHTML('beforeend', `<button class="btn-shopping-cart btn-shopping-neutral use-ajax" data-progress-type="fullscreen" href="/en/direct-buy/add-to-cart/${pid}">PA | Add to Cart</button>`) | |
} | |
Drupal.ajax.bindAjaxLinks(document); | |
if (details && details.querySelector('button')) { | |
details.querySelector('button').click(); | |
} | |
})(); |
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 () => { s=document.createElement('script'); s.innerHTML=(await (await fetch(`https://gist.githubusercontent.com/PartAlert/a9e8bb6f3b6709ba3a56665164f03978/raw/amd.js?v=${new Date().getTime()}`)).text()); document.body.appendChild(s); })() |
It shouldn't make any difference.
hi is there any script for amazonuk or currys uk .... so we can buy cards
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, is it possible that collecting the
language
(as well as thepid
) in the url to be reused in the buttonhref
may help ?Or maybe the
lang
parameter in the/add-to-cart/
call doesn't matter ?