Skip to content

Commit

Permalink
feat(ideogram): 每次都登录
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangsx committed Aug 30, 2024
1 parent e48aca1 commit 4d6ce17
Showing 1 changed file with 12 additions and 38 deletions.
50 changes: 12 additions & 38 deletions model/ideogram/child.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,6 @@ export class Child extends ComChild<Account> {
return this._client;
}

async saveCookies() {
const cookies = await this.page.cookies('https://ideogram.ai');
const session_cookie = cookies.find((v) => v.name === 'session_cookie');
if (!session_cookie) {
throw new Error('not found cookies');
}
this.update({ cookies });
this.logger.info('cookies saved ok');
}

async saveUA() {
const ua = await this.page.evaluate(() => navigator.userAgent.toString());
this.update({ ua });
Expand Down Expand Up @@ -115,34 +105,19 @@ export class Child extends ComChild<Account> {
}
this.update({ destroyed: false });
let page;
if (!this.info.cookies?.length) {
page = await CreateNewPage('https://ideogram.ai/login', {
proxy: this.proxy,
});
this.page = page;
// click login
await page.waitForSelector('.MuiButton-containedPrimary');
await page.click('.MuiButton-containedPrimary');
page = await CreateNewPage('https://ideogram.ai/login', {
proxy: this.proxy,
});
this.page = page;
// click login
await page.waitForSelector('.MuiButton-containedPrimary');
await page.click('.MuiButton-containedPrimary');

await loginGoogleNew(page, this.info);
await this.checkCreateProfile();
this.update({ proxy: this.proxy });
await this.saveUA();
await this.saveCookies();
await sleep(3 * 1000);
} else {
page = await CreateNewPage('https://ideogram.ai/t/explore', {
proxy: this.proxy,
cookies: this.info.cookies.map((v) => ({
...v,
url: 'https://ideogram.ai',
})),
});
this.page = page;
await page.waitForNavigation({ waitUntil: 'networkidle0' });
await this.saveUA();
await this.saveCookies();
}
await loginGoogleNew(page, this.info);
await this.checkCreateProfile();
this.update({ proxy: this.proxy });
await this.saveUA();
await sleep(3 * 1000);
await this.saveToken();
await this.saveUserID();
const av = await this.ImagesSamplingAvailable();
Expand Down Expand Up @@ -327,7 +302,6 @@ export class Child extends ComChild<Account> {
{},
)
).data;
await this.saveCookies();
return data;
}

Expand Down

0 comments on commit 4d6ce17

Please sign in to comment.