Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (async function(codes) {
- const delay = (mult = 1) => new Promise(r => setTimeout(r, (1500 + Math.random() * 500) * mult));
- const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;
- let mult = 1;
- for (let i = 0; i < codes.length; i++) {
- const input = document.getElementById('redeemCode');
- const btn = document.getElementById('submit-code-btn');
- nativeInputValueSetter.call(input, codes[i]);
- input.dispatchEvent(new Event('input', { bubbles: true }));
- await delay(mult);
- btn.click();
- await delay(mult);
- btn.click();
- await delay(mult);
- const helper = document.getElementById('redeemCode-helper-text');
- const helperText = helper ? helper.textContent.trim() : '';
- if (helperText.includes('too frequent')) {
- mult *= 2;
- console.log(`[${i + 1}/${codes.length}] ${codes[i]} → Throttled! Delay ${mult}x. Retrying...`);
- i--;
- } else if (helperText) {
- mult = 1;
- console.log(`[${i + 1}/${codes.length}] ${codes[i]} → ${helperText}`);
- } else {
- const snackbar = document.getElementById('notifications-snackbar');
- const snackText = snackbar ? snackbar.textContent.trim() : '';
- if (snackText.includes('Successfully redeemed code')) {
- mult = 1;
- console.log(`[${i + 1}/${codes.length}] ${codes[i]} → ${snackText}`);
- } else {
- mult *= 2;
- console.log(`[${i + 1}/${codes.length}] ${codes[i]} → No response detected. Delay ${mult}x. Retrying...`);
- i--;
- }
- }
- }
- console.log('All codes processed!');
- })([
- "TODO",
- "TODO",
- "TODO"
- ]);
Advertisement
Add Comment
Please, Sign In to add comment