Skip to content

Instantly share code, notes, and snippets.

@lart2150
Created April 5, 2022 23:30
Show Gist options
  • Select an option

  • Save lart2150/74893fa262106fe06df8ede53df16d5c to your computer and use it in GitHub Desktop.

Select an option

Save lart2150/74893fa262106fe06df8ede53df16d5c to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Add AMX offfers to card
// @namespace https://lart2150.com/
// @version 0.1
// @description Add all Amx offers to card
// @author /u/lart2150
// @match https://global.americanexpress.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=americanexpress.com
// @grant GM_registerMenuCommand
// ==/UserScript==
const run = async () => {
'use strict';
console.log('Adding offers to card');
for (let a of document.querySelectorAll('[title="Add to Card"]')) {
await (new Promise(resolve => setTimeout(resolve, 1000)));
a.click();
}
};
const loop = () => {
if (document.querySelectorAll('[title="Add to Card"]').length === 0) {
setTimeout(loop, 1000);
console.log('no offers waiting to run');
} else {
run();
}
}
setTimeout(loop, 1000);
GM_registerMenuCommand('Add All Offers to card', function() {
run();
}, 'o')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment