Skip to content

Instantly share code, notes, and snippets.

@artchen
Last active October 12, 2025 19:49
Show Gist options
  • Select an option

  • Save artchen/291baba03d2b44346b0a0cf7326cae33 to your computer and use it in GitHub Desktop.

Select an option

Save artchen/291baba03d2b44346b0a0cf7326cae33 to your computer and use it in GitHub Desktop.
Add US Bank Offers
// ==UserScript==
// @name Add USBank offers
// @namespace http://tampermonkey.net/
// @version 2025-10-12
// @description - _-
// @author Art Chen
// @match https://onlinebanking.usbank.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=usbank.com
// @grant none
// ==/UserScript==
const selectors = {
addOfferButton: '[data-testid="activate-offer"]',
activateOfferButton: '#activate-offer',
offerBackButton: '#close-action'
};
function wait(delay) {
return new Promise(resolve => setTimeout(resolve, delay));
}
async function waitForElement(sel, max = 3) {
const el = document.body.querySelector(sel);
if (el || max === 0) {
return el;
}
await wait(500);
return waitForElement(sel, max - 1);
}
function makeButton() {
const button = document.createElement('button');
button.id = "add-all-offers-button";
button.textContent = 'Add all offers';
const findOffers = () => {
const allOffers = [...document.querySelectorAll(selectors.addOfferButton)].filter(btn => !btn.textContent.includes('Activated'));
button.textContent = `Remaining Offers: ${allOffers.length}. Please wait...`;
return allOffers;
};
async function addOffer() {
const offers = findOffers();
if (!offers.length) {
button.textContent = `All offers added. Click to restart.`;
window.scrollTo({
top: 0,
left: 0,
behavior: "smooth",
});
return;
}
offers[0].click();
const activateOfferButton = await waitForElement(selectors.activateOfferButton);
if (activateOfferButton) {
activateOfferButton.click();
}
const closeModalButton = await waitForElement(selectors.offerBackButton);
if (closeModalButton) {
closeModalButton.click();
}
await wait(1000);
await addOffer();
}
button.addEventListener('click', addOffer);
return button;
}
function makeStyle() {
const styleEl = document.createElement('style');
const css = `
#add-all-offers-button {
position: fixed;
z-index: 100001;
right: 20px;
top: 60px;
transition: background 0.24s;
background: #ffffff;
border: 0;
border-radius: 5px;
padding: 0 15px;
height: 36px;
align-items: center;
appearance: none;
background-color: #FCFCFD;
box-shadow: rgba(45, 35, 66, 0.4) 0 2px 4px, rgba(45, 35, 66, 0.3) 0 7px 13px -3px, #D6D6E7 0 -3px 0 inset;
box-sizing: border-box;
color: #36395A;
cursor: pointer;
display: inline-flex;
justify-content: center;
line-height: 1;
list-style: none;
overflow: hidden;
text-decoration: none;
transition: box-shadow .15s, background .15s, transform .15s;
user-select: none;
-webkit-user-select: none;
touch-action: manipulation;
white-space: nowrap;
will-change: box-shadow, transform;
font-size: 14px;
}
#add-all-offers-button:hover {
box-shadow: rgba(45, 35, 66, 0.4) 0 4px 8px, rgba(45, 35, 66, 0.3) 0 7px 13px -3px, #D6D6E7 0 -3px 0 inset;
transform: translate3d(0, -2px, 0);
}
#add-all-offers-button:active {
box-shadow: #D6D6E7 0 3px 7px inset;
transform: translate3d(0, 2px, 0);
}
`;
styleEl.type = 'text/css';
styleEl.appendChild(document.createTextNode(css));
return styleEl;
}
(async function() {
'use strict';
const addAllOfferButton = makeButton();
document.body.prepend(addAllOfferButton);
const styleEl = makeStyle();
document.head.appendChild(styleEl);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment