您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Clip all the coupons on the current (as of 02/05/2025) Safeway Just For U coupon system.
// ==UserScript== // @name Safeway For U Coupon Clipper // @include https://www.safeway.com/foru/coupons-deals.html* // @description Clip all the coupons on the current (as of 02/05/2025) Safeway Just For U coupon system. // @version 1.0 // @namespace https://greasyfork.org/users/864548 // ==/UserScript== // While the load more button exists, load more function loadUntilDone() { let buttons = document.getElementsByClassName('load-more') if (buttons.length > 0) { // Still a load more button. Click until it goes away console.log("Loading more coupons...") try { buttons[0].click() } catch (e) { console.error(e) } // Give it some time to load. setTimeout(loadUntilDone, 1000) } else { // Now find and click all the coupons console.log("Clicking all coupons...") clickAllUnclicked(document.querySelectorAll('[id^="couponAddBtn"]')) } } /// Resolve after the given delay async function sleep(delay) { return new Promise((resolve, reject) => { setTimeout(resolve, delay) }) } /// Click on every element in the given collection, at a sensible pace, unless alredy clicked async function clickAllUnclicked(elems) { for (let i = 0; i < elems.length; i++) { let elem = elems[i]; if (!elem.classList.contains('btn btn-md btn-primary w-100 p-0')) { console.log("Click element " + i + ": " + elem) elem.click() await sleep(1000) } } console.log("All coupons clicked!") } // Wait for the page to load and then start collecting coupons console.log("Waiting to load coupons") setTimeout(loadUntilDone, 4000)