您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Automatically skip optional Ocado checkout steps (ads/gifts), including after SPA navigation and delayed render.
// ==UserScript== // @name Ocado auto-next when checking out (Robust SPA Fix) // @namespace http://tampermonkey.net/ // @version 2025-07-05 // @description Automatically skip optional Ocado checkout steps (ads/gifts), including after SPA navigation and delayed render. // @author. pepepepepe // @match https://ww2.ocado.com/* // @grant none // @license MIT // ==/UserScript== (function () { 'use strict'; const TARGET_TEXTS = [ "Continue checkout", "No free gift" ]; function clickMatchingElements() { const elements = document.querySelectorAll('a, button'); let clicked = false; for (const el of elements) { const text = el.textContent?.trim(); if (!text) continue; if (TARGET_TEXTS.some(target => text.includes(target))) { el.click(); console.log(`✅ Clicked: "${text}"`); clicked = true; } } return clicked; } // Retry logic that waits for dynamic DOM rendering function waitAndClick(attempt = 0) { const maxAttempts = 30; const delay = 500; // ms if (clickMatchingElements()) { console.log("✅ Button found and clicked."); return; } if (attempt < maxAttempts) { setTimeout(() => waitAndClick(attempt + 1), delay); } else { console.warn("⚠️ Button not found after retries."); } } // Run on initial page load waitAndClick(); // Detect SPA navigation let lastUrl = location.href; setInterval(() => { if (location.href !== lastUrl) { lastUrl = location.href; console.log("🔄 URL changed:", lastUrl); waitAndClick(); } }, 500); })();