Skip to content

Instantly share code, notes, and snippets.

@S0PEX
Last active September 28, 2021 18:15
Show Gist options
  • Save S0PEX/cd8388fffcacddd14d8d12591d3ff47f to your computer and use it in GitHub Desktop.
Save S0PEX/cd8388fffcacddd14d8d12591d3ff47f to your computer and use it in GitHub Desktop.
Visa.js
const puppeteer = require("puppeteer");
async function start() {
const browser = await puppeteer.launch({
headless: false,
userDataDir: "./session",
});
const page = await browser.newPage();
const formData = {
"#cardData_cardNumber": "",
"#cardData_expiryDate": "",
"#cardData_csc": "",
"#paypalAccountData_firstName": "Vorname",
"#paypalAccountData_lastName": "Nachname",
"#paypalAccountData_address1": "Straße 31",
"#paypalAccountData_zip": "PLZ",
"#paypalAccountData_city": "BA",
"#paypalAccountData_phone": "017600000000",
"#paypalAccountData_email": "email@email.de",
};
try {
for (var i = 0; i < 21; i++) {
// go to afd
await page.goto("https://www.afd.de/spenden/");
await page.$eval(
'form[action="https://www.paypal.com/donate"][target="_top"]',
(form) => form.submit()
);
await page.waitForNavigation();
await page.type("#currencyAmount", "0.01");
await page.click("#payWithGuest");
await page.waitForSelector("#paypalAccountData_email");
// fill form
for (const [key, value] of Object.entries(formData)) {
await page.type(key, value, { delay: 100 });
}
await page.click("#guestPaymentBtn");
await page.waitForNavigation();
}
} catch (e) {
if (e instanceof puppeteer.errors.TimeoutError) {
// Do something if this is a timeout.
}
} finally {
await browser.close();
}
}
start();
{
"name": "Visa",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"puppeteer": "^10.2.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment