Skip to content

Instantly share code, notes, and snippets.

@beacrea
Last active August 16, 2016 16:01
Show Gist options
  • Save beacrea/ac781d23a29d7bc641245da3bbfe6165 to your computer and use it in GitHub Desktop.
Save beacrea/ac781d23a29d7bc641245da3bbfe6165 to your computer and use it in GitHub Desktop.
/*
Example SKARSTA
Desk sit/stand, white
Article Number: 490.849.65
Length: 47 1/4"
Width: 27 1/2"
http://www.ikea.com/us/en/catalog/availability/S49084965
STORE LIST
209 - AZ, Tempe
160 - CA, Burbank
162 - CA, Carson
167 - CA, Costa Mesa
413 - CA, Covina
347 - CA, East Palo Alto
165 - CA, Emeryville
166 - CA, San Diego
157 - CA, West Sacramento
064 - CO, Centennial
213 - CT, New Haven
327 - FL, Miami
145 - FL, Orlando
207 - FL, Sunrise
042 - FL, Tampa
257 - GA, Atlanta
170 - IL, Bolingbrook
210 - IL, Schaumburg
374 - KS, Merriam
158 - MA, Stoughton
152 - MD, Baltimore
411 - MD, College Park
026 - MI, Canton
212 - MN, Twin Cities
410 - MO, St. Louis
067 - NC, Charlotte
154 - NJ, Elizabeth
409 - NJ, Paramus
462 - NV, Las Vegas
921 - NY, Brooklyn
156 - NY, Long Island
175 - OH, West Chester
028 - OR, Portland
211 - PA, Conshohocken
153 - PA, Pittsburgh
215 - PA, South Philadelphia
183 - TX, Dallas
379 - TX, Houston
027 - TX, Round Rock
103 - UT, Draper
168 - VA, Woodbridge
250 - WA, Seattle
*/
// Navigate To Product
var product = prompt('Enter Article Number', 'Format: 000.000.00').replace(/\./g,'');
window.location.replace("http://www.ikea.com/us/en/catalog/availability/S" + product);
// Select KS And Check Store
document.getElementById('localStoreSelector').value='374';
document.getElementById('jsButton_IrwStockCheck_04').click();
// Get Stock Info Text After Load
// Pseudocode - Replace with real, CasperJS code
window.onload = function() {
var stockInfo = document.getElementsByClassName("sc_com_stockInfo")[0].textContent;
if (stockInfo.includes("out of stock")) {
console.log('Out Of Stock!');
} else if (stockInfo.includes("in stock")) {
console.log('In Stock!!');
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment