The basic javascript console code in Google Chrome for availability is as below
- iPhone7availability Select all
// proper case string prptotype (JScript 5.5+)
String.prototype.toProperCase = function()
{
return this.toLowerCase().replace(/^(.)|\s(.)/g,
function($1) { return $1.toUpperCase(); });
}
function testip7plus() {
var targetProduct = "Plus"
var targetCapacity = "256GB" // "32GB", "128GB", "256GB"
var targetColor = "Silver" // "Rose Gold" 玫瑰金色, "Gold" 金色, "Sliver" 銀色, "Black" 黑色, "Jet Black" 亮黑色
var FinalSelectedProduct = false;
targetCapacity = targetCapacity.toUpperCase()
targetColor = targetColor.toProperCase();
var stores_length = $('form#availabilityForm #selectStore option[disabled!=disabled]').length;
for(a=0; a<stores_length; a++) {
var enabledStore = $('form#availabilityForm #selectStore option[disabled!=disabled]').eq(a).val();
setTimeout(function() {
$('form#availabilityForm div.form-element.select-store select').val(enabledStore);
$('form#availabilityForm div.form-element.select-store select').change();
},1800)
var enabledStoreText = $('form#availabilityForm #selectStore option[disabled!=disabled]').eq(a).text().replace(/^\s+|\s+$/g, '');
var products_length = $('form#availabilityForm #selectSubfamily option[disabled!=disabled]').length;
for(p=0; p<products_length; p++) {
var enabledProduct = $('div#productSelectionView #selectSubfamily option[disabled!=disabled]').eq(p).val();
var enabledProductText = $('div#productSelectionView #selectSubfamily option[disabled!=disabled]').eq(p).text();
if (~enabledProductText.toLowerCase().indexOf(targetProduct.toLowerCase())) {
console.log("Log " + enabledStoreText + " has " + enabledProductText);
$('form#availabilityForm div.form-element.select-product select').val(enabledProduct);
$('form#availabilityForm div.form-element.select-product select').change();
var unavailableGB = $('div#capacity-row li.unavailable input[value="'+targetCapacity+'"]').length
console.log("Log " + enabledStoreText + " checking for " + targetCapacity)
if (unavailableGB == 0) {
var sizeAva_length = $('div#capacity-row li').length;
for(u=0;u<sizeAva_length;u++) {
if ($('div#capacity-row li').eq(u).find('div').attr('id') == targetCapacity) {
$('div#capacity-row li').eq(u).find("input").click();
break;
}
}
var unavailableColor = $('div#product-row li.unavailable input[data-color="'+targetColor+'"]').length
console.log("Log " + enabledStoreText + " checking for " + targetColor)
if (unavailableColor == 0) {
var colorAva_length = $('div#product-row li').length;
for(v=0;v<colorAva_length;v++) {
if ($('div#product-row li').eq(v).find('input').attr('data-color') == targetColor) {
setTimeout(function() {
$('div#product-row li').eq(v).find("input").click();
},800)
FinalSelectedProduct = true;
break;
}
}
if (FinalSelectedProduct) {
console.log("SUCCESS!!! " + enabledStoreText + " has " + $('div.section-product.product-bottom.hide-for-large.show-only-for-small.with-fade.fade-in div.product div.callout.callout-center.product-specs ul.specs li:first').text().trim() + " " + enabledProductText + $('div.success.row div.success-copy.small-center').text().trim());
break;
}
}
else {
console.log("Log " + enabledStoreText + ", sorry no " + targetCapacity + " " + targetColor)
}
}
}
else {
console.log(enabledStoreText + ", sorry no " + targetProduct)
}
}
if (FinalSelectedProduct) {
return;
}
}
}
testip7plus()
There is an archive for iPhone 6 Availability script in last year, please click the Chrome CSS Javascript label below