Greasy Fork

Ocado auto-next when checking out

Skip through all optional pages once you decide to checkout

当前为 2025-07-03 提交的版本,查看 最新版本

// ==UserScript==
// @name         Ocado auto-next when checking out
// @namespace    http://tampermonkey.net/
// @version      2025-04-30
// @description  Skip through all optional pages once you decide to checkout
// @author       pepepepepe
// @match        https://www.ocado.com/webshop/beforeYouGo*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=ocado.com
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    const TARGET_TEXTS = [
        "Continue checkout",
        "No free gift"
    ];

    function clickTargetButtons() {
        const buttons = document.getElementsByTagName('button');
        let clickedAny = false;

        for (const button of buttons) {
            const btnText = button.textContent.trim();

            if (TARGET_TEXTS.some(target => btnText.includes(target))) {
                button.click();
                console.log(`Clicked: "${btnText}"`);
                clickedAny = true;
                // Don't return here - allow multiple clicks if needed
            }
        }

        return clickedAny;
    }

    function attemptClicks() {
        if (!clickTargetButtons()) {
            console.log("Target buttons not found yet...");
        }
    }

    // Initial attempt
    window.addEventListener('load', attemptClicks);

    // Monitor DOM changes
    const observer = new MutationObserver(attemptClicks);
    observer.observe(document.body, { childList: true, subtree: true });
})();