Advertisement
tzAria

AMD bookmark

Jun 5th, 2021
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. javascript: (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]}">TW | Add To Cart</button>`) }); const details = document.querySelector('#product-details-info%20.product-page-description');%20%20%20%20if%20(details%20&&%20pid%20&&%20!details.querySelector('button'))%20{%20%20%20%20%20%20%20%20details.insertAdjacentHTML('beforeend',%20`<button%20class="btn-shopping-cart%20btn-shopping-neutral%20use-ajax"%20data-progress-type="fullscreen"%20href="/en/direct-buy/add-to-cart/${pid}">TW%20|%20Add%20to%20Cart</button>`)%20%20%20%20}%20%20%20%20Drupal.ajax.bindAjaxLinks(document);%20%20%20%20if%20(details%20&&%20details.querySelector('button'))%20{%20%20%20%20%20%20%20%20details.querySelector('button').click();%20%20%20%20}})();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement