2022-06-15 18:12:55 +02:00

641 lines
18 KiB
TypeScript

import cheerio from "cheerio";
import { isTypeReferenceNode } from "typescript";
export namespace Template {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
return false;
} catch (error) {
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace FitnessKoerier {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($('.product-list .stock-msg').find("[itemprop=availability]").attr("content") == "out_of_stock") {
return false;
} else {
return true;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace FitnessApparaat {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($('[itemprop="offers"]').find(".stock-red").length >= 1) {
return false;
} else {
return true;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace BolCom {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($('[data-test="outofstock-buy-block"]').length >= 1) {
return false;
} else {
return true;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace BeterSport {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
return false;
if ($('.product-shop .in-stock').first().html() !== null) {
if ($('.product-shop .in-stock').first().html().trim() == "Niet op voorraad, neem contact op voor actuele informatie") {
return false;
}
else if ($('.product-shop .in-stock').first().html().trim().includes("week")) {
return false;
}
else {
return true;
}
} else {
return true;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace FitnessGeest {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($('.product-info-box .in_stock_message').length >= 1) {
return true;
} else {
return false;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace BodyAndFit {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($('.product-page .product-cart-controls .btn__primary').first().attr("disabled")) {
return false;
} else {
return true;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace GorillaSports {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($('.product_buy .button_sold_out').length >= 1) {
return false;
} else {
return true;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace PerfectBody {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($('.product.type-product').first().hasClass("instock")) {
return true;
} else {
return false;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace BCC {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($(".productoffer__availability .productoffer__deliverymsg .icon").first().length >= 1) {
return true;
} else {
return false;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace Alternate {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($(".productMainContainerRow .stockStatus.available_stock").length >= 1) {
if ($(".productMainContainerRow .stockStatus.available_stock").first().html().trim().toLocaleLowerCase() >= "direct leverbaar") {
return true;
} else {
return false;
}
} else {
return false;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace Expert {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($(".product__view .product__add-to-cart").length >= 1) {
return true;
} else {
return false;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace Conrad {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($(".product-summary .availability__status")) {
if ($(".product-summary .availability__status").first().html().trim().toLowerCase() == "available") {
return true;
}
}
return false;
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace Silvergear {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($('.product.type-product').first().hasClass("instock")) {
return true;
} else {
return false;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace AlsaNature {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($('.product .inventoryStatus .icon').first().hasClass("icon-in_stock")) {
return true;
} else {
return false;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace Dobey {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($("#product_view #stock_indicator").hasClass("stock_green")) {
return true;
} else {
return false;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace EzyDog {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($(".product-shop .availability").first().hasClass("in-stock")) {
return true;
} else {
return false;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace K9Shop {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($(".ty-qty-in-stock i").first().hasClass("ty-icon-ok")) {
return true;
} else {
return false;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace OnlineHondenSpeciaalZaak {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($("#Product #StockContainer #ShowOutOfStock").hasClass("hidden")) {
return true;
} else {
return false;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace MacroVet {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($('.product-essential meta[itemprop=availability]').attr("href") == "http://schema.org/InStock") {
return true;
}
if ($(".row-products-blog .row-products-blog2 .active link").attr("href") == "http://schema.org/InStock") {
return true;
}
return false;
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace PetDuka {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($("#product .hurry i").first().hasClass("icon-check-white")) {
return true;
} else {
return false;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace PetsOnline {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($("#content #product_configure_form .overlay-e i").first().hasClass("icon-check-circle")) {
return true;
} else {
return false;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace PetsPlace {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($(".product-info-main #product-addtocart-button").length >= 1) {
return true;
} else {
return false;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace ZooEnzo {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($(".row.main_content .availability .available-now link").attr("href") == "http://schema.org/InStock") {
return true;
} else {
return false;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace ThePetEmpire {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($("#content .form-product .add-to-cart-button").length >= 1) {
return true;
} else {
return false;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace HuisdierExpress {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($("[itemprop=availability]").first().attr("content") == "in_stock") {
return true;
}
return false;
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace HondenBed {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($("[itemprop=availability]").first().attr("content") == "http://schema.org/InStock") {
return true;
}
return false;
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace Coolblue {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
let stock = false;
$('script[type="application/ld+json"]').each((index, element) => {
let json = JSON.parse($(element).html());
if (json["@type"]) {
if (json["@type"] == "Product") {
if (json["offers"]["availability"] == "http://schema.org/InStock") {
stock = true;
return;
}
}
}
});
return stock;
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace WifiMedia {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($("[itemprop=availability]").first().attr("content") == "http://schema.org/InStock") {
return true;
}
return false;
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace Ep {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($(".product__info").find(".is-green").html()) {
return true;
}
return false;
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace Kinq {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($(".product-detail-infomation").find(".stock")) {
if ($(".product-detail-infomation").find(".stock").first().attr("style") == "color: #2ace48;") {
return true;
}
}
return false;
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace Maxiaxi {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
let stock = false;
$('script[type="application/ld+json"]').each((index, element) => {
let json = JSON.parse($(element).html());
if (json["@type"]) {
if (json["@type"] == "Product") {
if (json["offers"][0]["availability"] == "http://schema.org/InStock") {
stock = true;
return;
}
}
}
});
return stock;
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace FotoDeVakman {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
let stock = false;
$('script[type="application/ld+json"]').each((index, element) => {
let json = JSON.parse($(element).html());
if (json["@type"]) {
if (json["@type"] == "Product") {
if (json["offers"]["availability"] == "http://schema.org/InStock") {
stock = true;
return;
}
}
}
});
return stock;
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace Kabels {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($(".product-info-main").find(".stock .available").first()) {
return true;
}
return false;
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}