Last active
March 5, 2020 13:27
-
-
Save ayan4m1/05cf1925abbcc12bbe8caddccb3d9d37 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// ==UserScript== | |
// @name FastTech Stock Checker | |
// @namespace http://phreak.space/ | |
// @version 0.0.2 | |
// @description Show the stock info on the FastTech search page. | |
// @author ayan4m1 <[email protected]> | |
// @match https://www.fasttech.com/search* | |
// @match https://www.fasttech.com/category/* | |
// @require https://code.jquery.com/jquery-3.3.1.min.js | |
// @require https://gist.githubusercontent.com/BrockA/2625891/raw/9c97aa67ff9c5d56be34a55ad6c18a314e5eb548/waitForKeyElements.js | |
// @grant none | |
// ==/UserScript== | |
$.noConflict(); | |
(function() { | |
'use strict'; | |
waitForKeyElements('#Products_Grid', (node) => { | |
jQuery('#Products_Grid').find('.ProductGridItem').each((i, v) => { | |
const elem = jQuery(v); | |
if (elem.find('.GridItemSoldOut').length > 0 || | |
elem.find('.GridItemEOL').length > 0) { | |
elem.remove(); | |
} else { | |
setTimeout(() => { | |
const url = elem.find('.GridItemName a').attr('href'); | |
jQuery.ajax({ url }).done(result => { | |
const status = jQuery('<div />').html(result).find('meta[itemprop="availability"]').next().text().trim(); | |
if (status !== 'In stock') { | |
elem.remove(); | |
} else { | |
elem.find('.GridItemName').after(`<div style="line-height:20px;color:green;">${status}</p>`); | |
elem.find('.GridItemPrimaryCategory').remove(); | |
} | |
}); | |
}, 750 * i); | |
} | |
}); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment