mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-04-25 22:16:59 +08:00
同步master最新代码
This commit is contained in:
parent
836bf7393a
commit
9dbe2184dd
@ -3,7 +3,7 @@ import login from "../login";
|
||||
|
||||
export async function getLink(options) {
|
||||
const log = clog(options)
|
||||
log('开始', { ident: 'gpt-link' })
|
||||
log('开始', { ident: 'gpt-link', ...options })
|
||||
const [page, browser] = await login.chatgpt({ ...options, changeUS: false })
|
||||
|
||||
// await page.waitForTimeout(500)
|
||||
@ -25,7 +25,7 @@ export async function getLink(options) {
|
||||
await page.click('.gold-new-button')
|
||||
|
||||
const [response] = await Promise.all([
|
||||
page.waitForNavigation({ waitUntil: 'domcontentloaded' }),
|
||||
page.waitForNavigation({ waitUntil: 'domcontentloaded', timeout: 0 }),
|
||||
page.evaluate((selector, searchText) => {
|
||||
const elements = Array.from(document.querySelectorAll(selector));
|
||||
const target = elements.find(el => el.textContent.trim() === searchText);
|
||||
|
@ -15,7 +15,7 @@ ipcMain.handle('gpt-link', async (event, arg) => {
|
||||
const links = []
|
||||
for(let i = 0; i < accounts.length; i++) {
|
||||
const [user, pass] = accounts[i]
|
||||
const link = await getLink({ user, pass, index: i, id: user })
|
||||
const link = await getLink({ user, pass, index: i, id: user, ...arg })
|
||||
links.push({
|
||||
i,
|
||||
user,
|
||||
|
@ -156,7 +156,7 @@ const login = {
|
||||
|
||||
log('启动浏览器')
|
||||
|
||||
const { browser, page } = await browserAndPage(options)
|
||||
const { browser, page } = await browserAndPage({ ...options, changeUS: false })
|
||||
|
||||
log('准备进入 gpt 登录')
|
||||
await page.goto('https://platform.openai.com')
|
||||
@ -319,7 +319,7 @@ const login = {
|
||||
GPASS: options.pass
|
||||
}
|
||||
|
||||
const { browser, page } = await browserAndPage(options)
|
||||
const { browser, page } = await browserAndPage({ ...options, changeUS: false })
|
||||
log('开始访问 gpt')
|
||||
await page.goto('https://chat.openai.com/auth/login')
|
||||
await page.waitForSelector('button')
|
||||
|
193
electron/main/poe/cookie.ts
Normal file
193
electron/main/poe/cookie.ts
Normal file
@ -0,0 +1,193 @@
|
||||
import type { Browser, Page } from 'puppeteer'
|
||||
import puppeteer from 'puppeteer-extra'
|
||||
import StealthPlugin from 'puppeteer-extra-plugin-stealth'
|
||||
import { browserAndPage, browsers, clog, createPromise, statusCheck } from "../tools"
|
||||
import login from '../login'
|
||||
puppeteer.use(StealthPlugin())
|
||||
|
||||
export async function getCookie(options) {
|
||||
console.log('options', options);
|
||||
const log = clog(options)
|
||||
log('开始', { ident: 'link_7day' })
|
||||
|
||||
let { p, resolve, reject } = createPromise<string>()
|
||||
|
||||
login.mail_get_code({ ...options, changeUS: false }).then(async ([page, browser, options]) => {
|
||||
const isOk = await statusCheck(
|
||||
() => options.code,
|
||||
async () => {
|
||||
log('未获取验证码,重试一次', { ident: 'link_7day' })
|
||||
options.code = await options.validateCode()
|
||||
return options.code
|
||||
},
|
||||
{ interval: 4000 }
|
||||
)
|
||||
resolve(options.code)
|
||||
browser.close()
|
||||
})
|
||||
|
||||
const [page, browser] = await login.poe_email(options, async () => {
|
||||
const code = await p
|
||||
console.log('获取验证码结果', code)
|
||||
if (!code) {
|
||||
log('获取验证码失败', { ident: 'link_7day' })
|
||||
reject('获取验证码失败')
|
||||
throw '获取验证码失败'
|
||||
}
|
||||
|
||||
return code
|
||||
}).catch(() => '' as any)
|
||||
|
||||
// 登录失败了
|
||||
if (!page) {
|
||||
console.log('登录失败了')
|
||||
browsers.map(b => b.close())
|
||||
return
|
||||
}
|
||||
|
||||
const cookies = await page.cookies()
|
||||
const token = cookies.find(v => v.name === 'p-b')?.value
|
||||
|
||||
log('获取token', { result: token })
|
||||
console.log('cookies', cookies)
|
||||
// browser.close()
|
||||
// await page.waitForTimeout(2000)
|
||||
browser.close()
|
||||
// const { page } = await login.poe_email(options)
|
||||
}
|
||||
|
||||
async function recharge(options: {
|
||||
browser: Browser,
|
||||
page: Page,
|
||||
user: string,
|
||||
liao: any,
|
||||
}) {
|
||||
const { browser, page, liao, ...args } = options
|
||||
const log = clog(args)
|
||||
log('开始充值')
|
||||
await page.waitForSelector('#cardNumber')
|
||||
|
||||
await page.evaluate(() => {
|
||||
const btn: HTMLElement = document.querySelector('.AddressAutocomplete-manual-entry .Link')
|
||||
if (btn) btn.click()
|
||||
})
|
||||
|
||||
await page.evaluate((email: string) => {
|
||||
const el: HTMLInputElement = document.querySelector('#email')
|
||||
if (el) el.value = email
|
||||
}, options.user)
|
||||
|
||||
await page.type('#cardNumber', liao.bank)
|
||||
await page.type('#cardExpiry', liao.date)
|
||||
await page.type('#cardCvc', liao.cvc)
|
||||
await page.type('#billingName', liao.name)
|
||||
await page.select('#billingCountry', liao.nation)
|
||||
await page.type('#billingAddressLine1', liao.address)
|
||||
await page.type('#billingLocality', liao.city)
|
||||
await page.type('#billingPostalCode', liao.postalCode)
|
||||
await page.waitForTimeout(1000)
|
||||
await page.click('.SubmitButton-IconContainer')
|
||||
|
||||
// await page.waitForTimeout(9000)
|
||||
|
||||
// await page.waitForSelector('iframe')
|
||||
// let $frame = await page.$('iframe')
|
||||
// let frame = await $frame.contentFrame()
|
||||
|
||||
// console.log('$frame', $frame)
|
||||
// // console.log('frame', frame)
|
||||
// await $frame.waitForSelector('iframe')
|
||||
// $frame = await frame.$('iframe')
|
||||
// frame = await $frame.contentFrame()
|
||||
// await frame.waitForSelector('iframe')
|
||||
// $frame = await frame.$('iframe')
|
||||
// frame = await $frame.contentFrame()
|
||||
|
||||
// await frame.waitForSelector('#checkbox', { timeout: 0 })
|
||||
// await frame.click('#checkbox')
|
||||
// await page.waitForNavigation()
|
||||
console.log('充值成功')
|
||||
log('充值成功')
|
||||
}
|
||||
|
||||
function existDialog(page: Page) {
|
||||
return page.evaluate((selector, searchText) => {
|
||||
const elements = Array.from(document.querySelectorAll(selector));
|
||||
const target = elements.find(el => el.textContent.trim() === searchText);
|
||||
target && target.click()
|
||||
|
||||
return !!target
|
||||
}, 'button', 'Start free trial')
|
||||
}
|
||||
|
||||
export async function getLink(options, [page, browser]: [Page, Browser]) {
|
||||
const log = clog(options)
|
||||
log('开始', { ident: 'poe-link' })
|
||||
await page.waitForTimeout(1000)
|
||||
const isExistDialog = await existDialog(page)
|
||||
|
||||
isExistDialog && log('检测到充值弹窗,无需前往设置页')
|
||||
|
||||
if (!isExistDialog) {
|
||||
await Promise.all([
|
||||
page.waitForNavigation(),
|
||||
page.goto('https://poe.com/settings')
|
||||
])
|
||||
log('已进入设置页面, 检查中')
|
||||
|
||||
const existMange = await page.evaluate(() => {
|
||||
const mange = document.querySelector('[class*="SettingsSubscriptionSection_manageSubscription"]')
|
||||
if (mange) return true
|
||||
return false
|
||||
})
|
||||
|
||||
if (existMange) {
|
||||
log('已经订阅')
|
||||
return
|
||||
}
|
||||
await page.waitForSelector('[class*=SettingsSubscriptionSection_subscribeButton]', { timeout: 0 })
|
||||
|
||||
page.waitForTimeout(500)
|
||||
log('点击显示订阅套餐按钮')
|
||||
// await page.click('[class*=SettingsSubscriptionSection_subscribeButton]')
|
||||
|
||||
const disabled = await page.$eval('[class*=SettingsSubscriptionSection_subscribeButton]', (el: HTMLButtonElement) => el.disabled)
|
||||
if (disabled) {
|
||||
log('订阅按钮不可用,地区不可用')
|
||||
return
|
||||
}
|
||||
|
||||
await statusCheck(
|
||||
async () => {
|
||||
return page.evaluate(() => {
|
||||
const $el = document.querySelector("[class*=SettingsSubscriptionSection_subscribeButton]")
|
||||
console.log('$el', $el)
|
||||
$el.click();
|
||||
})
|
||||
},
|
||||
// async () => page.click('[class*=SettingsSubscriptionSection_subscribeButton]'),
|
||||
async () => page.$('.Modal_modal__SxITf'),
|
||||
)
|
||||
}
|
||||
|
||||
// log('显示更多套餐')
|
||||
// await page.waitForSelector('[class*=WebSubscriptionFreeTrial_viewAllPlansButton]')
|
||||
// await page.click('[class*=WebSubscriptionFreeTrial_viewAllPlansButton]')
|
||||
// log('点击最后一个套餐')
|
||||
// await page.waitForSelector('[class*=WebSubscriptionPaywall_plans]')
|
||||
// await page.click('[class*=WebSubscriptionPaywall_plans] > button:last-child')
|
||||
|
||||
// 点击订阅
|
||||
log('4, 开始点击订阅')
|
||||
await page.waitForSelector('[class*=WebSubscriptionPaywall_button]', { timeout: 0 })
|
||||
page.click('[class*=WebSubscriptionPaywall_button]')
|
||||
const [response] = await Promise.all([
|
||||
page.waitForNavigation({ waitUntil: 'domcontentloaded' }),
|
||||
])
|
||||
|
||||
if (response.ok()) {
|
||||
const url = response._request._frame._url
|
||||
log('获取链接成功', { result: url, type: 'success' })
|
||||
return url
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ import { getLink } from './getLink'
|
||||
import { validate } from './validate'
|
||||
import { ipcMain } from 'electron'
|
||||
import { link_7day } from './link_7day'
|
||||
import { getCookie } from './cookie'
|
||||
import { browserAndPage } from '../tools'
|
||||
|
||||
export const parseAccount = text => text.split('\n').filter(Boolean).map(v => {
|
||||
@ -52,6 +53,29 @@ ipcMain.handle('get-poe-link-7day', async (event, arg) => {
|
||||
})
|
||||
|
||||
|
||||
|
||||
ipcMain.handle('get-poe-cookie', async (event, arg) => {
|
||||
const { text, liao } = arg
|
||||
const accounts = parseAccount(text)
|
||||
|
||||
const links = []
|
||||
for (let i = 0; i < accounts.length; i++) {
|
||||
const [user, pass, auxiliary] = accounts[i]
|
||||
const link = await getCookie({ user, pass, auxiliary, index: i, id: user, liao })
|
||||
// .catch(err => {
|
||||
// console.log('error ->', err)
|
||||
// })
|
||||
links.push({
|
||||
i,
|
||||
user,
|
||||
link
|
||||
})
|
||||
console.log('process', i, user, link)
|
||||
}
|
||||
return links
|
||||
})
|
||||
|
||||
|
||||
ipcMain.handle('poe-result', async (event, arg) => {
|
||||
const { text } = arg
|
||||
const accounts = parseAccount(text)
|
||||
|
@ -1,7 +1,7 @@
|
||||
import type { Browser, Page } from 'puppeteer'
|
||||
import puppeteer from 'puppeteer-extra'
|
||||
import StealthPlugin from 'puppeteer-extra-plugin-stealth'
|
||||
import { browserAndPage, browsers, clog, createPromise, statusCheck } from "../tools"
|
||||
import { awaitWrap, browserAndPage, browsers, clog, createPromise, statusCheck } from "../tools"
|
||||
import login from '../login'
|
||||
puppeteer.use(StealthPlugin())
|
||||
|
||||
@ -47,6 +47,7 @@ export async function link_7day(options) {
|
||||
|
||||
const url = await getLink(options, [page, browser])
|
||||
|
||||
return url
|
||||
if (url && options.liao) {
|
||||
await recharge({ ...options, page, browser })
|
||||
}
|
||||
@ -58,22 +59,13 @@ export async function link_7day(options) {
|
||||
}
|
||||
|
||||
async function test() {
|
||||
const url = 'https://checkout.stripe.com/c/pay/cs_live_a1SgJas9blPTFsRxVwdTA6Ox1mQxnfj4uDoF2yKUrO6ZjAnY7dXbo9qVsp#fidkdWxOYHwnPyd1blppbHNgWjxITDJsdEROY3Y1NjZpNTc8Q1RMU3ZTNicpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPyd2bGtiaWBabHFgaCcpJ2BrZGdpYFVpZGZgbWppYWB3dic%2FcXdwYHgl'
|
||||
const liao = {
|
||||
"bank": "5445446852620225",
|
||||
"cvc": "233",
|
||||
"date": "07/25",
|
||||
"name": "Miguel",
|
||||
"address": "5615 E 127th Ave Apt c",
|
||||
"city": "Tampa",
|
||||
"postalCode": "33613",
|
||||
"nation": "US"
|
||||
}
|
||||
const url = 'https://checkout.stripe.com/c/pay/cs_live_a1MXhrEYuI3qJEjw85zmuIxjFsgswafv0xlcxUGAOIeyiGJBGLA56mvRto#fidkdWxOYHwnPyd1blppbHNgWjxITDJsdEROY3Y1NjZpNTc8Q1RMU3ZTNicpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPyd2bGtiaWBabHFgaCcpJ2BrZGdpYFVpZGZgbWppYWB3dic%2FcXdwYHgl'
|
||||
const liao = {"bank":"4833160230060672","cvc":"04/26","date":"722","name":"Zackary Wais","address":"1200LakeshoreaveApt8G","city":"Oakland","postalCode":"94606","nation":"US"}
|
||||
const user = 'neletegcongder@mail.com'
|
||||
|
||||
const { page, browser } = await browserAndPage()
|
||||
await page.goto(url)
|
||||
recharge({ browser, page, user, liao })
|
||||
await recharge({ browser, page, user, liao })
|
||||
}
|
||||
|
||||
// test()
|
||||
@ -94,10 +86,12 @@ async function recharge(options: {
|
||||
if (btn) btn.click()
|
||||
})
|
||||
|
||||
await page.evaluate((email: string) => {
|
||||
const isEmail = await page.evaluate((email: string) => {
|
||||
const el: HTMLInputElement = document.querySelector('#email')
|
||||
if (el) el.value = email
|
||||
return !!el
|
||||
}, options.user)
|
||||
if (isEmail) await page.type('#email', options.user)
|
||||
|
||||
|
||||
await page.type('#cardNumber', liao.bank)
|
||||
await page.type('#cardExpiry', liao.date)
|
||||
@ -110,7 +104,15 @@ async function recharge(options: {
|
||||
await page.waitForTimeout(1000)
|
||||
await page.click('.SubmitButton-IconContainer')
|
||||
|
||||
// await page.waitForTimeout(9000)
|
||||
// await page.waitForTimeout(8000)
|
||||
|
||||
// const [error, config] = await awaitWrap(page.solveRecaptchas())
|
||||
// if (error) {
|
||||
// log('充值失败', { result: '充值失败', })
|
||||
// } else {
|
||||
// console.log(config)
|
||||
// log('充值成功', { result: '充值成功', })
|
||||
// }
|
||||
|
||||
// await page.waitForSelector('iframe')
|
||||
// let $frame = await page.$('iframe')
|
||||
@ -118,7 +120,7 @@ async function recharge(options: {
|
||||
|
||||
// console.log('$frame', $frame)
|
||||
// // console.log('frame', frame)
|
||||
// await $frame.waitForSelector('iframe')
|
||||
// await frame.waitForSelector('iframe')
|
||||
// $frame = await frame.$('iframe')
|
||||
// frame = await $frame.contentFrame()
|
||||
// await frame.waitForSelector('iframe')
|
||||
@ -127,7 +129,7 @@ async function recharge(options: {
|
||||
|
||||
// await frame.waitForSelector('#checkbox', { timeout: 0 })
|
||||
// await frame.click('#checkbox')
|
||||
// await page.waitForNavigation()
|
||||
await page.waitForNavigation()
|
||||
console.log('充值成功')
|
||||
log('充值成功')
|
||||
}
|
||||
|
@ -100,10 +100,12 @@ export async function browserAndPage (options: any = {}) {
|
||||
const args = [
|
||||
'--no-sandbox',
|
||||
'--disable-setuid-sandbox',
|
||||
'--disable-web-security',
|
||||
'--disable-features=IsolateOrigins,site-per-process,SitePerProcess',
|
||||
'--flag-switches-begin --disable-site-isolation-trials --flag-switches-end'
|
||||
]
|
||||
|
||||
// proxy ? args.push(await proxyCommand()) : null
|
||||
console.log(args, proxy);
|
||||
proxy ? args.push(await proxyCommand()) : null
|
||||
|
||||
// proxy ? args.push(await proxyCommand()) : ''
|
||||
|
||||
|
44
src/App.vue
44
src/App.vue
@ -89,7 +89,7 @@ const listSuccess = computed(() => {
|
||||
})
|
||||
|
||||
function copyAllSuccess() {
|
||||
const text = listSuccess.value.map((item) => `${item.user}\n${item.result}`).join('\n\n')
|
||||
const text = listSuccess.value.map((item, i) => `${i + 1}. ${item.user}----${item.result}`).join('\n')
|
||||
copyText(text)
|
||||
}
|
||||
|
||||
@ -190,9 +190,26 @@ const columns = [
|
||||
}
|
||||
]
|
||||
|
||||
const keys = ['getLink', 'poe-result', 'gpt-link', 'gpt-result', 'gpt-batch-4.0', 'gpt-batch-4.0-result']
|
||||
function handler () {
|
||||
function getLiao() {
|
||||
let liaoObj
|
||||
if (liao.value) {
|
||||
const [_1, bank, cvc, cardExpiry, name, address, city, _2, postalCode, nation] = liao.value.split('|').map(v => v.trim())
|
||||
liaoObj = { bank, cvc, date: cardExpiry, name, address, city, postalCode, nation }
|
||||
copy(JSON.stringify(liaoObj))
|
||||
}
|
||||
return liaoObj
|
||||
}
|
||||
|
||||
function handler(proxyType, name) {
|
||||
const isProxy = proxyType === 'proxy'
|
||||
console.log(proxyType, name, isProxy)
|
||||
let liaoObj
|
||||
// if (liao.value) {
|
||||
// const [_1, bank, cvc, cardExpiry, name, address, city, _2, postalCode, nation] = liao.value.split('|').map(v => v.trim())
|
||||
// liaoObj = { bank, cvc, date: cardExpiry, name, address, city, postalCode, nation }
|
||||
// }
|
||||
|
||||
ipcRenderer.invoke(name, { text: input.value, liao: liaoObj, proxy: isProxy })
|
||||
}
|
||||
|
||||
</script>
|
||||
@ -204,24 +221,29 @@ function handler () {
|
||||
<textarea class="textarea w-full min-w-100 max-w-94vw" v-model="input" rows="20" />
|
||||
|
||||
<p>liao:</p>
|
||||
<NSpace>
|
||||
<NInput class="textarea w-full min-w-100 max-w-94vw" v-model:value="liao" />
|
||||
<NButton @click="getLiao">复制</NButton>
|
||||
</NSpace>
|
||||
|
||||
<div>
|
||||
<div flex gap-3 mt-3 items-center>
|
||||
<span w-15>poe:</span>
|
||||
<TheButton type="primary" dashed @click="getLink()">提取链接</TheButton>
|
||||
<TheButton type="primary" dashed @click="getResult()">充值结果</TheButton>
|
||||
<TheButton type="warning" dashed @click="getLink_7day()">提取链接-7天</TheButton>
|
||||
<TheButton type="primary" dashed @select="key => handler(key, 'getLink')">提取链接</TheButton>
|
||||
<TheButton type="primary" dashed @select="key => handler(key, 'poe-result')">充值结果</TheButton>
|
||||
<TheButton type="warning" dashed @select="key => handler(key, 'get-poe-link-7day')">提取链接-7天</TheButton>
|
||||
<TheButton type="warning" dashed @select="key => handler(key, 'get-poe-cookie')">获取cookie</TheButton>
|
||||
</div>
|
||||
<div flex gap-3 mt-3 items-center>
|
||||
<span w-15>gpt4.0:</span>
|
||||
<TheButton type="primary" dashed @click="application()">申请4.0</TheButton>
|
||||
<TheButton type="primary" dashed @click="applicationResult()">检查申请结果(mail邮箱)</TheButton>
|
||||
<TheButton type="primary" dashed @select="key => handler(key, 'gpt-batch-4.0')">申请4.0</TheButton>
|
||||
<TheButton type="primary" dashed @select="key => handler(key, 'gpt-batch-4.0-result')">检查申请结果(mail邮箱)
|
||||
</TheButton>
|
||||
</div>
|
||||
<div flex gap-3 mt-3 items-center>
|
||||
<span w-15>gpt plus:</span>
|
||||
<NButton type="primary" dashed @click="gptLinkHandler">gpt提链</NButton>
|
||||
<NButton type="primary" dashed @click="gptResultHandler">充值结果</NButton>
|
||||
<span w-15 class="whitespace-nowrap">gpt plus:</span>
|
||||
<TheButton type="primary" dashed @select="key => handler(key, 'gpt-link')">gpt提链</TheButton>
|
||||
<TheButton type="primary" dashed @select="key => handler(key, 'gpt-result')">充值结果</TheButton>
|
||||
</div>
|
||||
<div flex gap-3 mt-3 items-center>
|
||||
<span w-15>操作:</span>
|
||||
|
@ -5,7 +5,7 @@ const options = [
|
||||
key: 'notProxy',
|
||||
},
|
||||
{
|
||||
label: '加代理',
|
||||
label: '加代理(port: 40000)',
|
||||
key: "proxy"
|
||||
},
|
||||
]
|
||||
@ -13,7 +13,7 @@ const options = [
|
||||
const emits = defineEmits(['select'])
|
||||
|
||||
const handler = (key: string) => {
|
||||
console.log(key);
|
||||
|
||||
emits('select', key)
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node",
|
||||
"strict": true,
|
||||
"noImplicitAny": false,
|
||||
"jsx": "preserve",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user