pg: PG_REDEEM, fixes for gog, #5
This commit is contained in:
parent
240e64ae4c
commit
e4ebae3744
1 changed files with 21 additions and 7 deletions
|
|
@ -163,15 +163,16 @@ try {
|
||||||
if (store == 'gog.com') {
|
if (store == 'gog.com') {
|
||||||
// await page.goto(`https://redeem.gog.com/v1/bonusCodes/${code}`); // {"reason":"Invalid or no captcha"}
|
// await page.goto(`https://redeem.gog.com/v1/bonusCodes/${code}`); // {"reason":"Invalid or no captcha"}
|
||||||
await page2.fill('#codeInput', code);
|
await page2.fill('#codeInput', code);
|
||||||
const r = page2.waitForResponse(r => r.url().startsWith('https://redeem.gog.com/'));
|
// wait for responses before clicking on Continue and then Redeem
|
||||||
await page2.click('[type="submit"]');
|
// first there are requests with OPTIONS and GET to https://redeem.gog.com/v1/bonusCodes/XYZ?language=de-DE
|
||||||
// console.log(await page2.locator('.warning-message').innerText());
|
const r1 = page2.waitForResponse(r => r.request().method() == 'GET' && r.url().startsWith('https://redeem.gog.com/'));
|
||||||
const rt = await (await r).text();
|
await page2.click('[type="submit"]'); // click Continue
|
||||||
console.debug(` Response: ${rt}`);
|
// console.log(await page2.locator('.warning-message').innerText()); // does not exist if there is no warning
|
||||||
|
const r1t = await (await r1).text();
|
||||||
|
const reason = JSON.parse(r1t).reason;
|
||||||
// {"reason":"Invalid or no captcha"}
|
// {"reason":"Invalid or no captcha"}
|
||||||
// {"reason":"code_used"}
|
// {"reason":"code_used"}
|
||||||
// {"reason":"code_not_found"}
|
// {"reason":"code_not_found"}
|
||||||
const reason = JSON.parse(rt).reason;
|
|
||||||
if (reason && reason.includes('captcha')) {
|
if (reason && reason.includes('captcha')) {
|
||||||
redeem_action = 'redeem (got captcha)';
|
redeem_action = 'redeem (got captcha)';
|
||||||
console.error(' Got captcha; could not redeem!');
|
console.error(' Got captcha; could not redeem!');
|
||||||
|
|
@ -183,7 +184,20 @@ try {
|
||||||
console.error(' Code was not found!');
|
console.error(' Code was not found!');
|
||||||
} else { // TODO not logged in? need valid unused code to test.
|
} else { // TODO not logged in? need valid unused code to test.
|
||||||
redeem_action = 'redeemed?';
|
redeem_action = 'redeemed?';
|
||||||
console.log(' Redeemed successfully? Please report your Response from above (if it is new) in https://github.com/vogler/free-games-claimer/issues/5');
|
console.log(' Redeemed successfully? Please report your Responses (if new) in https://github.com/vogler/free-games-claimer/issues/5');
|
||||||
|
console.debug(` Response 1: ${r1t}`);
|
||||||
|
// then after the click on Redeem there is a POST request which should return {} if claimed successfully
|
||||||
|
const r2 = page2.waitForResponse(r => r.request().method() == 'POST' && r.url().startsWith('https://redeem.gog.com/'));
|
||||||
|
await page2.click('[type="submit"]'); // click Redeem
|
||||||
|
const r2t = await (await r2).text();
|
||||||
|
console.debug(` Response 2: ${r2t}`);
|
||||||
|
if (r2t == '{}') {
|
||||||
|
redeem_action = 'redeemed';
|
||||||
|
console.log(' Redeemed successfully.');
|
||||||
|
} else {
|
||||||
|
redeem_action = 'redeemed?';
|
||||||
|
console.log(' Unknown Response 2 - please report in https://github.com/vogler/free-games-claimer/issues/5');
|
||||||
|
}
|
||||||
// db.data[user][title].status = 'claimed and redeemed';
|
// db.data[user][title].status = 'claimed and redeemed';
|
||||||
}
|
}
|
||||||
} else if (store == 'microsoft games') {
|
} else if (store == 'microsoft games') {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue