Skip to content

Instantly share code, notes, and snippets.

@chnbohwr
Created November 24, 2017 08:31
Show Gist options
  • Save chnbohwr/6c4faed771a1aef2bd0b3cb662603959 to your computer and use it in GitHub Desktop.
Save chnbohwr/6c4faed771a1aef2bd0b3cb662603959 to your computer and use it in GitHub Desktop.
const selectSize = (size) => {
const selector = document.querySelector('#exp-pdp-buying-tools-container > form > div.exp-pdp-size-and-quantity-container > div > div.exp-pdp-size-dropdown-container.nsg-form--drop-down--option-container.selectBox-options.nsg-form--drop-down.exp-pdp-size-dropdown.exp-pdp-dropdown.two-column-dropdown.selectBox-dropdown-menu > ul');
const children = Array.from(selector.children);
children.forEach(ele => {
const rel = ele.getAttribute('rel');
if (rel.substring(rel.indexOf(':'), rel.length) === `:${size}`) {
console.log('find ele', ele);
$('select[name="skuAndSize"]').val(rel);
$('#buyingtools-add-to-cart-button').click();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment