Tool Daz3D Whislist filter checkbox

mowu

New Member
Jun 9, 2018
4
13
I created a javascript script to add a new filter to the Daz3D site. It adds the Only Show Wishlisted checkbox filter

1714092332079.png

Description
This is script update the current page to add the filter, since is temporal you would need to add the filter each time you update the page.
When the new filter is checked it disabled the Hide Items I Own filter since it shouldn't make any change when only showing wishlisted items because when buying an item it should remove the wishlist mark.


Use

Option 1 -
:
  • Create a new Bookmark copying the Script into the URL field
1714094210965.png
  • While on the Daz 3D site, click in the bookmark to add the filter

Option 2 - Dev Tools console
  • While on the Daz 3D site, open Dev Tools in your browser and go to the Console tab
1714094544759.png
  • Copy & paste the script on the console Tab and press Enter to add the filter

Last update
2024-04-25: Post
2024-05-02 : Update format


Script
JavaScript:
javascript: (() => {    
/* Exit the script if already added */
    if (document.getElementById("large_wishlist")) return;

    /*Override to include new filter*/
    daz.filter.cleanFilter = (filterSettings) => {
        "use strict";
        var whitelist = ["category", "shopCategories", "compat_figures", "compat_software", "genre", "platClub", "mature", "vendor", "owned", "inCart", "enterprise", "bundle", "omit", "new", "wishlist"];
        for (var filterType in filterSettings) {
            if (!filterSettings.hasOwnProperty(filterType) || -1 === whitelist.indexOf(filterType)) {
                delete filterSettings[filterType]
            }
        }
        return filterSettings
    };

    /*Override filter method to include new filter*/
    daz.filter.filterProducts = (productList, filterSettings, force = false) => {
        if (productList === null) {
            productList = []
        }

        if (!daz.filter.hasLoaded && !force) {
            return productList
        }

        if (productList === true) {
            productList = [];
            for (let id in daz.filter.sorts.date) {
                productList.push(id)
            }
        }

        filterSettings = daz.filter.cleanFilter(filterSettings);
        filterSettings.enterprise = null;
        if (typeof daz.cart != "undefined" && typeof daz.cart.enterprise != "undefined") {
            filterSettings.enterprise = daz.cart.enterprise
        }

        if (filterSettings.enterprise) {
            delete filterSettings["platClub"]
        }

        if (typeof filterSettings.platClub == "object") {
            if (filterSettings.platClub[0] == "yes" || filterSettings.platClub[0] == 1) {
                filterSettings.platClub = 1
            } else {
                filterSettings.platClub = 0
            }
        }

        if (typeof filterSettings.bundle == "object") {
            if (filterSettings.bundle[0] == "yes" || filterSettings.bundle[0] == 1) {
                filterSettings.bundle = true
            } else {
                filterSettings.bundle = false
            }
        }

        const ignoreList = ["omit", "owned", "inCart", "new", "platClub", "enterprise", "shopCategories", "mature", "bundle","wishlist"];

        for (let filterType in filterSettings) {
            let newList = [];
            if (ignoreList.indexOf(filterType) !== -1) {
                continue
            }

            if (filterSettings[filterType].length == 0) {
                continue
            }

            for (let i = 0; i < productList.length; i++) {
                let id = productList[i];
                let foundIt = false;
                for (let ii = 0; ii < filterSettings[filterType].length; ii++) {
                    let filterOpt = filterSettings[filterType][ii];
                    if (filterType == "category" && !daz.filter.filters.category[filterOpt]) {
                        daz.filter.buildCategoryFilter(filterOpt)
                    }
                    if (daz.filter.filters[filterType][filterOpt] != undefined && daz.filter.filters[filterType][filterOpt][id]) {
                        foundIt = true
                    }

                    if (foundIt) {
                        newList.push(id)
                    }
                }

            }

            productList = newList
        }

        let newList = [];
        if (filterSettings.bundle === true) {
            let bundleList = [];
            for (let i = 0; i < productList.length; i++) {
                let id = productList[i];
                if (daz.filter.filters.bundle.yes[id] == true == filterSettings.bundle) {
                    bundleList.push(id)
                }
            }
            productList = bundleList
        }

        if (typeof filterSettings.owned != "undefined" && filterSettings.owned == true) {
            newList = [];
            for (let i = 0; i < productList.length; i++) {
                let id = productList[i];
                if (typeof daz.filter.filters.owned[id] == "undefined") {
                    newList.push(id)
                }
            }
            productList = newList
        }

        if (typeof filterSettings.inCart != "undefined") {
            newList = [];
            for (let i = 0; i < productList.length; i++) {
                let id = productList[i];
                if (daz.filter.filters.inCart[id] == true == filterSettings.inCart) {
                    newList.push(id)
                }
            }
            productList = newList
        }

        if (filterSettings.omit && filterSettings.omit.length > 0) {
            newList = [];
            filterSettings.omit.forEach(function (productId) {
                productList.forEach(function (id) {
                    if (productId != id) {
                        newList.push(id)
                    }
                })
            });

            productList = newList
        }

        if (typeof filterSettings.new != "undefined" && null !== filterSettings.new) {
            newList = [];
            for (let i = 0; i < productList.length; i++) {
                let id = productList[i];
                if (daz.filter.filters.new.yes[id] == true == filterSettings.new) {
                    newList.push(id)
                }
            }
            productList = newList
        }

        if (typeof filterSettings.platClub != "undefined" && null !== filterSettings.platClub) {
            platClubList = [];
            for (let i = 0; i < productList.length; i++) {
                let id = productList[i];
                if (daz.filter.filters.platClub.yes[id] == true == filterSettings.platClub) {
                    platClubList.push(id)
                }
            }
            productList = platClubList
        }

        if (filterSettings.enterprise === true) {
            let enterpriseList = [];
            for (let i = 0; i < productList.length; i++) {
                let id = productList[i];
                if (daz.filter.filters.enterprise.yes[id] == true == filterSettings.enterprise) {
                    enterpriseList.push(id)
                }
            }
            productList = enterpriseList
        }

        if (filterSettings.wishlist === true) {
            let inWishlist = [];
            for (let i = 0; i < productList.length; i++) {
                let id = productList[i];
                if (daz.filter.filters.inWishlist[id] == true) {
                    inWishlist.push(id)
                }
            }
            productList = inWishlist
        }
        return productList;
    };

    /*Setup new checkbox*/
    daz.catalog.setupFiltersExtra = () => {
        daz.catalog.setupFilters();
        $('#large_wishlist input[type="checkbox"]').on("change", $.proxy((event) => {
            var check = false;
            if (daz.catalog.filterSettings.wishlist !== true) {
                daz.catalog.filterSettings.wishlist = true;
                check = true;
            } else {
                delete daz.catalog.filterSettings.wishlist;
                check = false;
            }
            daz.api.sessionStoragePut("wishlist", check);
            $(".wishlist_check").prop("checked", check);
            $(".owned_check").prop('disabled', check); /*Disable own checkbox since it would do nothing with this checkbox*/
            if (event) event.stopPropagation();
            daz.catalog.applyFilters(true)
        }, daz.catalog));
    };

    /*Declare new checkbox for InWishlist filter*/
    let inWishlistCheckbox = `
    <span id="large_wishlist" class="hide-enterprise cursor-pointer filter-checkbox">
        <label>
            <input class="wishlist_check" type="checkbox" value="yes">
            <span>
                Only Show Wishlisted
            </span>
        </label>
    </span>
    `;

    /*Insert new checkbox after Only show DazPlus*/
    $( inWishlistCheckbox ).insertAfter( "#large_platClub" );

    /*Apply setup*/
    daz.catalog.setupFiltersExtra();
})();
 
Last edited: