|
// ==UserScript== |
|
// @name Amazon Gaming "Claim All Games" button |
|
// @namespace http://tampermonkey.net/ |
|
// @version 0.2 |
|
// @description Adds a button below "Games free with Prime" to click all "Claim game" buttons; Does not click on external offerings |
|
// @author nakami |
|
// @match http*://gaming.amazon.com/* |
|
// @icon https://d2u4zldaqlyj2w.cloudfront.net/02b601d4-a3ab-41e5-b8ab-1083f15f1c68/favicon.ico |
|
// @grant none |
|
// @run-at document-idle |
|
// ==/UserScript== |
|
|
|
/* |
|
Support me by donating to my PayPal: |
|
https://www.paypal.com/donate/?hosted_button_id=VNDER8T6AZ732 |
|
Thank you! |
|
*/ |
|
|
|
(function() { |
|
'use strict'; |
|
|
|
function claimAll() { |
|
console.log('Claim All Games'); |
|
let claimBtns = document.querySelectorAll('[data-a-target="offer-section-FGWP_FULL"] button[data-a-target="FGWPOffer"]'); |
|
//let claimExternalBtns = document.querySelectorAll('[data-a-target="offer-section-FGWP_FULL"] button[data-a-target="ExternalOfferClaim"]'); |
|
console.log("found number of buttons:" + claimBtns.length); |
|
for (var i = 0, len = claimBtns.length; i < len; i++) { |
|
claimBtns[i].click(); |
|
} |
|
}; |
|
|
|
function sleep(ms) { |
|
return new Promise(resolve => setTimeout(resolve, ms)); |
|
} |
|
|
|
sleep(2000).then(() => { |
|
let title = Array.from(document.getElementsByClassName("offer-list__section-title")).at(-1); |
|
let newBtn = document.createElement('button'); |
|
newBtn.setAttribute('class', 'tw-interactive tw-button tw-button--prime'); |
|
let newSpan = document.createElement('span'); |
|
newSpan.setAttribute('class', 'tw-button__text'); |
|
newBtn.appendChild(newSpan); |
|
let newP = document.createElement('p'); |
|
newP.setAttribute('class', 'tw-amazon-ember-regular tw-font-size-6 tw-lg-font-size-6 tw-md-font-size-6 tw-sm-font-size-6 tw-xl-font-size-6 tw-xs-font-size-6 tw-xxl-font-size-6'); |
|
newBtn.onclick = claimAll; |
|
newP.textContent = 'Claim All Games'; |
|
newSpan.appendChild(newP); |
|
title.parentNode.insertBefore(newBtn, title.nextSibling); |
|
}); |
|
})(); |