Last active
October 12, 2025 19:33
-
-
Save artchen/27fc4779891dccd9c3dfc7bc2c5c7f84 to your computer and use it in GitHub Desktop.
Add AMEX Offers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Add AMEX offers | |
| // @namespace http://tampermonkey.net/ | |
| // @version 2025-10-12 | |
| // @description - _- | |
| // @author Art Chen | |
| // @match https://global.americanexpress.com/* | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=americanexpress.com | |
| // @grant none | |
| // ==/UserScript== | |
| const buttonId = 'add-all-amex-offer'; | |
| function waitForSampleButton() { | |
| return new Promise((resolve) => { | |
| const sampleButton = document.querySelector('[data-testid="merchantOfferDetailsLink"]'); | |
| if (sampleButton) { | |
| resolve(sampleButton); | |
| return; | |
| } | |
| setTimeout(() => { | |
| waitForSampleButton().then((btn) => resolve(btn)); | |
| }, 1000); | |
| }); | |
| } | |
| function makeButton(sampleButton) { | |
| const button = sampleButton.cloneNode(true); | |
| const span = button.querySelector('span'); | |
| span.textContent = 'Add all offers'; | |
| span.style.borderColor = "green"; | |
| span.style.color = "green"; | |
| span.style.borderWidth = "2px"; | |
| button.style.marginRight = "20px"; | |
| button.style.cursor = "pointer"; | |
| button.id = buttonId; | |
| button.addEventListener('click', async () => { | |
| const offerButtons = Array.from(document.querySelectorAll("[title='add to list card']")); | |
| for (let i = 0; i < offerButtons.length; ++i) { | |
| offerButtons[i].click(); | |
| await new Promise(r => setTimeout(r, 2000)); | |
| span.textContent = `Added ${i + 1} / ${offerButtons.length}`; | |
| } | |
| window.scrollTo({ | |
| top: 0, | |
| left: 0, | |
| behavior: "smooth", | |
| }); | |
| }); | |
| return button; | |
| } | |
| (async function() { | |
| 'use strict'; | |
| const sampleButton = await waitForSampleButton(); | |
| const myButton = makeButton(sampleButton); | |
| const slotEl = document.querySelector('[data-testid="sortMenu"]'); | |
| slotEl.after(myButton); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment