Skip to content

Instantly share code, notes, and snippets.

@nakami
Created January 28, 2022 16:27
Show Gist options
  • Save nakami/2f8e60f09a6686a27e435c336f585fce to your computer and use it in GitHub Desktop.
Save nakami/2f8e60f09a6686a27e435c336f585fce to your computer and use it in GitHub Desktop.
Adds a button to the Payback website to activate all coupons
// ==UserScript==
// @name Activate All Payback Coupons
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Activating all Coupons on Payback.de with one click
// @author nakami
// @copyright 2022 nakami
// @license GNU General Public License v2.0
// @include http*://www.payback.de/coupons*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
// @require http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js
// @grant none
// ==/UserScript==
(function() {
'use strict';
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
let mainSR = undefined;
let coupons = undefined;
sleep(2000).then(() => {
var span = document.createElement("span");
span.innerHTML = '<input type="button" href="javascript:void(0);" title="Activate all Coupons" value="Activate all Coupons">';
span.addEventListener("click", function(){
alert('Starting the Work');
mainSR = document.querySelector("#coupon-center").shadowRoot;
coupons = mainSR.querySelectorAll("pbc-coupon");
coupons.forEach((coupon) =>
{
try {
coupon.shadowRoot.querySelector("pbc-coupon-call-to-action").shadowRoot.querySelector('button.not-activated').click();
} catch (error) {
console.error(error);
}
})
}, false);
document.querySelector('#coupon-center').shadowRoot.querySelector("div.coupon-center__filter").append(span);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment