28 lines
744 B
TypeScript
28 lines
744 B
TypeScript
import { Database } from "./database";
|
|
import { BrowserContext } from "./browser";
|
|
|
|
function dmm(db: Database, ctx: BrowserContext) {
|
|
return {
|
|
async login() {
|
|
const page = await ctx.newPage();
|
|
await page.goto("https://accounts.dmm.com/service/login/password");
|
|
await page.waitForURL("https://www.dmm.com/", { timeout: 0 });
|
|
const secrets = await ctx.storageState();
|
|
await ctx.close();
|
|
await db.run(
|
|
`update platforms set secrets = ? where name = 'dmm-books'`,
|
|
JSON.stringify(secrets),
|
|
);
|
|
},
|
|
};
|
|
}
|
|
|
|
export function createPlatform(db: Database, ctx: BrowserContext) {
|
|
const platform = dmm(db, ctx);
|
|
|
|
return {
|
|
async login() {
|
|
await platform.login();
|
|
},
|
|
};
|
|
}
|