Walmart Persistent In-Store Filter

Automatically applies the in-store filter to all search results

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Walmart Persistent In-Store Filter
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Automatically applies the in-store filter to all search results
// @author       Rim
// @tag          shopping
// @license      GNU GPLv3
// @match        https://*.walmart.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function applyFilter() {
        const url = new URL(window.location.href);

        // Check if we're on a search page and don't already have the facet
        if (url.pathname === '/search' && url.searchParams.has('q')) {
            const currentFacet = url.searchParams.get('facet');
            const targetFacet = 'fulfillment_method_in_store:In-store';

            // Only add if the facet isn't already present
            if (currentFacet !== targetFacet) {
                url.searchParams.set('facet', targetFacet);
                window.location.replace(url.href);
            }
        }
    }

    // Run on initial load
    applyFilter();

    // Watch for URL changes (for single-page app navigation)
    let lastUrl = location.href;
    new MutationObserver(() => {
        const currentUrl = location.href;
        if (currentUrl !== lastUrl) {
            lastUrl = currentUrl;
            applyFilter();
        }
    }).observe(document, { subtree: true, childList: true });
})();