您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Automatically set the Ocado price dropdown with name="sortBy" to "Price per: Low to High". Skip through all "continue checkout" buttons
// ==UserScript== // @name Ocado Price Sorter and fast checkout // @namespace http://tampermonkey.net/ // @version 1.1 // @description Automatically set the Ocado price dropdown with name="sortBy" to "Price per: Low to High". Skip through all "continue checkout" buttons // @author Pepe // @match https://www.ocado.com/* // @icon https://www.google.com/s2/favicons?domain=ocado.com // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // Function to set the dropdown to "Price per: Low to High" function setDropdown() { // Wait for the dropdown to exist in the DOM const dropdownInterval = setInterval(() => { const dropdown = document.querySelector('select[name="sortBy"]'); if (dropdown) { clearInterval(dropdownInterval); // Set the value to "Price per: Low to High" for (const option of dropdown.options) { if (option.textContent.includes("Price per: Low to High")) { dropdown.value = option.value; dropdown.dispatchEvent(new Event('change', { bubbles: true })); break; } } } }, 500); } function clickCheckoutButton() { let buttons = document.querySelectorAll('button, input[type="button"], input[type="submit"]'); for (let button of buttons) { if (button.textContent.trim() === "Continue checkout") { console.log("Clicking 'Continue checkout' button."); button.click(); return; } } } // Run on page load clickCheckoutButton(); // Run the function when the page loads window.addEventListener('load', setDropdown); // Detect changes in the search results using MutationObserver const observer = new MutationObserver(setDropdown); observer.observe(document.body, { childList: true, subtree: true }); // Detect changes in the URL (e.g., when a new search is performed) let lastUrl = location.href; setInterval(() => { if (location.href !== lastUrl) { lastUrl = location.href; setDropdown(); } }, 1000); })();