Raw Source
dpriskorn / Hide products not in stock at Cycle Service Nordic

// ==UserScript==
// @name         Hide products not in stock at Cycle Service Nordic
// @namespace    Violentmonkey Scripts
// @version      0.1
// @description  This script reduces clutter in the webshop.
// @author       Dennis Priskorn
// @copyright    2021, dpriskorn (https://openuserjs.org/users/dpriskorn)
// @license      GPL-3.0-or-later
// @match        https://www.cycleservicenordic.com/*
// @icon         https://www.google.com/s2/favicons?domain=cycleservicenordic.com
// @grant        none
// @require      https://code.jquery.com/jquery-3.2.1.min.js
// @downloadURL  https://openuserjs.org/install/dpriskorn/Hide_products_not_in_stock.user.js
// @updateURL    https://openuserjs.org/meta/dpriskorn/Hide_products_not_in_stock.meta.js
// ==/UserScript==

(function() {
    'use strict';
    console.log("userscript is running")
    var rows = $(".product-list > div:nth-child(1)").children()
    $( rows ).each(function(index){
        console.log( index + ": " + $( this ).find(".product-name").children("span").text() );
        //console.log($(this))
        var inOfStock = $( this ).find("div.label-stock")
        var outOfStock = $( this ).find("div.restock-description")
        if ($(outOfStock).length > 0){
            console.log("found a product to be hidden");
            //console.log(outOfStock)
            $( this ).hide();
        }
        if ($(inOfStock).length > 0){
            console.log("found a product in stock");
            //console.log(inOfStock)
            //$( this ).hide();
        }
    })
})();