Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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();



I 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)


I 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/d572b5494a4f26390aeb5136d70...


This 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

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);


This is genius and a much more of a "hacker" way to do it... Sometimes simple is better


This 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...


jQuery? Shouldn't you be running a React front-end from a bookmarklet and figuring out a way to Dockerize it?


what does this do exactly?


> $(".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/

[2] https://api.jquery.com/click/


This 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”


To 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"


Uses javascript to find all the page elements with the coupon add button styling attributes and then uses javascript to click each add button.


*uses jquery


`$` is a built-in wrapper around `document.querySelector` in many popular browser consoles (along with `$$` for `document.querySelectorAll`).

Though of course if Safeway's website does have a global `$` from jquery then that would take precedence.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: