3 ms·
I did something similar with Safeway's API back in the day. But rather than chew up their API with unsupported usage--CFAA case territory--I now just log into S
by withinrafael 7y ago
I did something similar with Safeway's API back in the day. But rather than chew up their API with unsupported usage--CFAA case territory--I now just log into Safeway's website and issue a one-liner on the coupon page:
$(".grid-coupon-clip-button button").click();
- nahtnam 7y agoThis is genius and a much more of a "hacker" way to do it... Sometimes simple is better
- mlrtime 7y agowhat does this do exactly?
- rripken 7y agoUses javascript to find all the page elements with the coupon add button styling attributes and then uses javascript to click each add button.
- deleted 7y ago[deleted]
- guessmyname 7y ago> $(".grid-coupon-clip-button button").click(); > what does this do exactly? The command allows you to click all buttons in the page at once: • The dollar sign is an alias for jQuery [1]; • The text between double quotes is a CSS selector; • Select every DOM element with a “grid-coupon-clip-button” and “button” CSS class; • The thing at the end is a JavaScript function call which triggers an “onclick” event [2]; [1] https://jquery.com/ https://jquery.com/ [2] https://api.jquery.com/click/ https://api.jquery.com/click/
- altec3 7y agoThis is a great little write up, but the third bullet point should be: - Select every button with a parent element that has the css class “grid-coupon-clip-button”
- jimktrains2 7y agoTo be pedantic, it clicks on elements that are a button element that is the child (at any depth) of an element (of any type) that has at least the class of "grid-coupon-clip-button"
- jonluca 7y agoI did that for a while too, but realized the mental overhead wasn't really worth it - occasionally I'd get the super generic coupons of "Spend $20, get $2 back" and those were worth it, but most of the time I was adding coupons I'd never use. The mental effort of going to the site at all was what I was trying to circumvent - now I don't even need to think about it (the clearer abstraction is that going from "2 to 1" is a much less drastic jump than going from "1 to 0" - completely removing the overhead is what makes this worthwhile, IMO, not the actual speed of the actions)
- petarb 7y agoI use to use a similar bookmarklet that I would run on the Safeway Coupons page. But it stopped working after they moved away from Angular and I was too lazy to update it. https://gist.github.com/pbojinov/d572b5494a4f26390aeb5136d7097655 https://gist.github.com/pbojinov/d572b5494a4f26390aeb5136d70...
- gitgud 7y agoThis is what I was thinking the whole time reading and looking at the site images... why script all that, when you could simply click the buttons in the browser... Rube Goldberg Machine's are not good in software projects...
- tspike 7y agojQuery? Shouldn't you be running a React front-end from a bookmarklet and figuring out a way to Dockerize it?
- ihattendorf 7y agoThis will click the "Load more" button and also click all the coupons while waiting 500ms per click. https://www.safeway.com/justforu/coupons-deals.html https://www.safeway.com/justforu/coupons-deals.html for(let i=0;30>i;++i)setTimeout(function(){btn=document.querySelector("#coupon-grid_0 > div.coupon-grid-container > div.load-more-container > button");btn && btn.click()},1e3i);elems=document.querySelectorAll(".grid-coupon-clip-button button");for(let i=0;i<elems.length;++i)setTimeout(function(){elems[a].click()},500i);