Skip to content

Instantly share code, notes, and snippets.

@lastlink
Last active March 19, 2025 14:48
Show Gist options
  • Save lastlink/da8e7daf64af04fd320dcd0031a66c19 to your computer and use it in GitHub Desktop.
Save lastlink/da8e7daf64af04fd320dcd0031a66c19 to your computer and use it in GitHub Desktop.
Chase Card Add All Offers Activation Script
// ==UserScript==
// @name Chase offers
// @namespace http://tampermonkey.net/
// @version 2024-11-24
// @description Automatically add chase offers
// @author You
// @match https://secure.chase.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=chase.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
const urlPatterns = [/https:\/\/secure\.chase\.com\/web\/auth\/dashboard#\/dashboard\/merchantOffers\/offer-hub\?accountId=.*/,/https:\/\/secure\.chase\.com\/web\/auth\/dashboard#\/dashboard\/merchantOffers\/offerCategoriesPage\?accountId=.*/];
const btnSelection = '[role="button"][tabindex="0"] > :nth-child(2)';
//'.r9jbij9' manual button selection
const backFunction = () => {
// shadow root back button click
document.querySelectorAll(`[variant="back"]`)[0].shadowRoot.querySelectorAll(`#back-button`)[0].click();
// old back method
// window.history.back();
};
const a = () => {
backFunction();
setTimeout(checkUrlAndRun, Math.random() * 1000 + 300);
};
let count = 1;
const c = () => {
try {
const btns = [...document.querySelectorAll(btnSelection)]
.filter(b => b.querySelectorAll("mds-icon")[0] && b.querySelectorAll("mds-icon")[0].type !== 'ico_checkmark_filled');
const b = btns.pop();
if (!b) {
console.log('added all!');
return;
}
b.querySelectorAll("mds-icon")[0].click();
updateProgress(count, btns.length);
setTimeout(a, Math.random() * 1000 + 300);
document.querySelector(btnSelection).click();
} catch (e) {
checkUrlAndRun();
}
};
const updateProgress = (current, total) => {
console.log(`Remaining: ${total}`);
count++;
};
const waitForElements = () => {
const observer = new MutationObserver((mutations, observer) => {
if (document.querySelectorAll(btnSelection).length > 0) {
observer.disconnect();
c();
}
});
observer.observe(document.body, { childList: true, subtree: true });
};
const checkUrlAndRun = () => {
if (urlPatterns.some(urlPattern => urlPattern.test(window.location.href))) {
waitForElements();
}
};
// Initial check
checkUrlAndRun();
// Monitor URL changes
let oldHref = document.location.href;
const body = document.querySelector("body");
const observer = new MutationObserver(mutations => {
if (oldHref !== document.location.href) {
oldHref = document.location.href;
checkUrlAndRun();
}
});
observer.observe(body, { childList: true, subtree: true });
})();
!function(){"use strict";const e=[/https:\/\/secure\.chase\.com\/web\/auth\/dashboard#\/dashboard\/merchantOffers\/offer-hub\?accountId=.*/,/https:\/\/secure\.chase\.com\/web\/auth\/dashboard#\/dashboard\/merchantOffers\/offerCategoriesPage\?accountId=.*/],t='[role="button"][tabindex="0"] > :nth-child(2)',o=()=>{document.querySelectorAll('[variant="back"]')[0].shadowRoot.querySelectorAll("#back-button")[0].click(),setTimeout(n,1e3*Math.random()+300)};let c=1;const r=(e,t)=>{console.log(`Remaining: ${t}`),c++},l=()=>{new MutationObserver(((e,l)=>{document.querySelectorAll(t).length>0&&(l.disconnect(),(()=>{try{const e=[...document.querySelectorAll(t)].filter((e=>e.querySelectorAll("mds-icon")[0]&&"ico_checkmark_filled"!==e.querySelectorAll("mds-icon")[0].type)),l=e.pop();if(!l)return void console.log("added all!");l.querySelectorAll("mds-icon")[0].click(),r(c,e.length),setTimeout(o,1e3*Math.random()+300),document.querySelector(t).click()}catch(e){n()}})())})).observe(document.body,{childList:!0,subtree:!0})},n=()=>{e.some((e=>e.test(window.location.href)))&&l()};n();let a=document.location.href;const d=document.querySelector("body");new MutationObserver((e=>{a!==document.location.href&&(a=document.location.href,n())})).observe(d,{childList:!0,subtree:!0})}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment