Skip to content

Instantly share code, notes, and snippets.

@ayan4m1
Last active March 5, 2020 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayan4m1/05cf1925abbcc12bbe8caddccb3d9d37 to your computer and use it in GitHub Desktop.
Save ayan4m1/05cf1925abbcc12bbe8caddccb3d9d37 to your computer and use it in GitHub Desktop.
// ==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 <andrew@bulletlogic.com>
// @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