Skip to content

Instantly share code, notes, and snippets.

@artchen
Last active October 15, 2025 06:29
Show Gist options
  • Select an option

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

Select an option

Save artchen/da3ad9eb18252b27aae8aec243623af2 to your computer and use it in GitHub Desktop.
Add PayPal Offers
// ==UserScript==
// @name Add PayPal offers
// @namespace http://tampermonkey.net/
// @version 2025-08-16
// @description - _-
// @author Art Chen
// @match https://www.paypal.com/shopping*
// @match https://www.paypal.com/offers*
// @icon https://www.google.com/s2/favicons?sz=64&domain=paypal.com
// @grant none
// ==/UserScript==
const selectors = {
addOfferButton: 'button[data-cy="base_offer_card__auto_save"]:not([disabled])',
showMoreButton: '[data-cy="tertiary_card_list__show_more_button"]'
};
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);
button.textContent = `Remaining Offers: ${allOffers.length}. Please wait...`;
return allOffers;
};
function loadMoreOffers() {
const loadOfferBtn = document.querySelector(selectors.showMoreButton);
if (!loadOfferBtn) {
return false;
}
loadOfferBtn.click();
try {
return true;
} catch (e) {
console.log('No more offer');
return false;
}
}
async function addOffer() {
const nextOffer = findOffers()[0];
if (nextOffer) {
nextOffer.click();
setTimeout(addOffer, 1000);
return;
}
if (loadMoreOffers()) {
setTimeout(addOffer, 5000);
return;
}
button.textContent = `All offers added. Click to restart.`;
window.scrollTo({
top: 0,
left: 0,
behavior: "smooth",
});
}
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: 100px;
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.body.prepend(styleEl);
})();
@KINGRDZ
Copy link

KINGRDZ commented Apr 3, 2024

utility pls ?

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