Hacker News new | ask | show | jobs
by ashconnor 587 days ago
Add all Amex offers:

    javascript: var index,offerButtons=Array.from(document.getElementsByClassName("offer-cta")).filter(a=>"Add to Card"==a.title);for(index=0;index<offerButtons.length;++index)console.log("Clicking offer button"),offerButtons[index].click(),(async()=>{await new Promise(a=>setTimeout(a,2e3))})();
Force paste (works sometimes)

    javascript:forceBrowserDefault=(e=>{e.stopImmediatePropagation();return true;});['copy','cut','paste'].forEach(e=>document.addEventListener(e,forceBrowserDefault,true));
Facebook Marketplace delete all sold

    javascript:(async()=>{var e,l,a=Array.from(document.getElementsByClassName("x193iq5w")).filter(e=>"Sold"==e.innerHTML);for(let i=0;i<a.length;++i)console.log("Clicking Sold Listing"),a[i].click(),await new Promise(e=>setTimeout(e,3e3)),document.querySelector('[aria-label="Save"]').click(),await new Promise(e=>setTimeout(e,1e3)),document.querySelector('[aria-label="Close"]').click(),await new Promise(e=>setTimeout(e,2e3));location.reload()})();
I should really convert these to Tampermonkey scripts
1 comments

i think this works for the Amex one. where do you run/test this?

  javascript:for (let b of document.querySelectorAll('.offer-cta[title="Add to Card"]')) {
    console.log("Clicking offer button");
    b.click();
    (async () => {await new Promise(r => setTimeout(r, 2e3))})();
  }
does the setTimeout work? wouldn't you need something like this (in an async function)

  for (let b of document.querySelectorAll('.offer-cta[title="Add to Card"]')) {
    console.log('Clicking offer button');
    b.click();
    await new Promise(r => setTimeout(r, 2e3));
  }
I run it on the offers page https://global.americanexpress.com/offers/eligible

The wrapped async function is for Firefox I understand.