Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save brgmn/f7aa1db058b87e03698b6c99a432edd5 to your computer and use it in GitHub Desktop.
Save brgmn/f7aa1db058b87e03698b6c99a432edd5 to your computer and use it in GitHub Desktop.
Bookmarklet to trigger all meta business manager invoice pdf downloads at once
javascript:(async()=>{function wait(ms){return new Promise(r=>setTimeout(r,ms))}function simulateClick(el){if(!el)return;el.dispatchEvent(new MouseEvent("mouseover",{bubbles:true}));el.dispatchEvent(new MouseEvent("mousedown",{bubbles:true}));el.click();el.dispatchEvent(new MouseEvent("mouseup",{bubbles:true}))}const pdfLinks=[...document.querySelectorAll('a[href*="pdf=true"]')];if(!pdfLinks.length){alert("No invoice links (pdf=true) found on this page.");return}alert("Found "+pdfLinks.length+" invoice(s). Downloading...");for(let link of pdfLinks){console.log("Triggering PDF download:",link.href);simulateClick(link);await wait(3000);}alert("All PDF downloads triggered!");})();
@brgmn
Copy link
Author

brgmn commented Feb 1, 2025

Use this at the "all transactions" page of an ad account starting with https://business.facebook.com/billing_hub/payment_activity...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment