mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-07-04 14:43:13 +08:00
准备替换所有 browser
This commit is contained in:
parent
8d5beec179
commit
7a5dfc0439
@ -15,19 +15,20 @@ puppeteer.use(StealthPlugin())
|
||||
function getProxy(options = {} as any) {
|
||||
const log = clog(options)
|
||||
log('开始获取代理ip')
|
||||
// return axios.get('https://tq.lunaproxy.com/getflowip?neek=1037914&num=1&type=1&sep=1®ions=us&ip_si=1&level=1&sb=', {
|
||||
// // return axios.get('https://www.miyaip.com/api/ProxyGenerage/PublicGenerateProxy?country=us&city=jaffrey®ion=nh&num=1&apiSwitch=0&mealType=2&genType=2&username=nmfk549724@163.com&secret=E3BCBmiyaipC23358C250F5', {
|
||||
// // return axios.get('http://api.tianqiip.com/getip?secret=loy0r7fpmnlshm8l&num=1&type=json&port=3&time=3&mr=1&sign=5f73ab58ad7ab40346311014bef59b79', {
|
||||
// timeout: 10 * 1000,
|
||||
// }).then(res => {
|
||||
// // const [user, pass] = res.data.split(':')
|
||||
// // return { user, pass, ip, port }
|
||||
// // // return axios.get('https://www.miyaip.com/api/ProxyGenerage/PublicGenerateProxy?country=us&city=cairo®ion=ny&num=1&apiSwitch=0&mealType=2&genType=2&username=nmfk549724@163.com&secret=E3BCBmiyaipC23358C250F5').then(res => {
|
||||
// const [ip, port] = res.data.replace(/(\n|\r\s)/g, '').split(':')
|
||||
// console.log({ ip, port, })
|
||||
// // const [ip, pory, user, pass] = res.data.split(':')
|
||||
// return { ip, port, }
|
||||
// })
|
||||
return axios.get('http://api.proxy.ipidea.io/getBalanceProxyIp?num=1&return_type=json&lb=1&sb=0&flow=1®ions=&protocol=socks5', {
|
||||
// return axios.get('https://www.miyaip.com/api/ProxyGenerage/PublicGenerateProxy?country=us&city=jaffrey®ion=nh&num=1&apiSwitch=0&mealType=2&genType=2&username=nmfk549724@163.com&secret=E3BCBmiyaipC23358C250F5', {
|
||||
// return axios.get('http://api.tianqiip.com/getip?secret=loy0r7fpmnlshm8l&num=1&type=json&port=3&time=3&mr=1&sign=5f73ab58ad7ab40346311014bef59b79', {
|
||||
timeout: 10 * 1000,
|
||||
}).then(res => {
|
||||
|
||||
// // const [user, pass] = res.data.split(':')
|
||||
// // return { user, pass, ip, port }
|
||||
// // // return axios.get('https://www.miyaip.com/api/ProxyGenerage/PublicGenerateProxy?country=us&city=cairo®ion=ny&num=1&apiSwitch=0&mealType=2&genType=2&username=nmfk549724@163.com&secret=E3BCBmiyaipC23358C250F5').then(res => {
|
||||
// const [ip, port] = res.data.replace(/(\n|\r\s)/g, '').split(':')
|
||||
// console.log({ ip, port, })
|
||||
// // const [ip, pory, user, pass] = res.data.split(':')
|
||||
return res.data.data[0]
|
||||
})
|
||||
return Promise.resolve({
|
||||
ip: '43.130.10.70',
|
||||
port: '22993',
|
||||
@ -48,16 +49,17 @@ async function login(options = {} as any): Promise<Page> {
|
||||
|
||||
// const [pErr, proxy] = await awaitWrap(getProxy(options))
|
||||
// if (pErr) {
|
||||
// console.log('获取代理失败', pErr)
|
||||
// log('获取代理失败')
|
||||
// return
|
||||
// }
|
||||
// console.log('获取代理成功', proxy)
|
||||
// // const proxyUrl = await proxyChain.anonymizeProxy(`socks5://${proxy.ip}:${proxy.port}`);
|
||||
// // console.log('获取代理成功', proxy)
|
||||
// // // const proxyUrl = await proxyChain.anonymizeProxy(`socks5://${proxy.ip}:${proxy.port}`);
|
||||
// const proxyUrl = `socks5://${proxy.ip}:${proxy.port}`
|
||||
// console.log('proxyUrl', proxyUrl)
|
||||
// // const agent = new SocksProxyAgent(`socks5://${proxy.user}:${proxy.pass}@${proxy.ip}:${proxy.port}`);
|
||||
// console.log(`curl --socks5 ${proxy.ip}:${proxy.port} https://jd.com`)
|
||||
// // // const agent = new SocksProxyAgent(`socks5://${proxy.user}:${proxy.pass}@${proxy.ip}:${proxy.port}`);
|
||||
|
||||
// // console.log('proxy', proxy)
|
||||
// // // console.log('proxy', proxy)
|
||||
|
||||
log('启动浏览器')
|
||||
|
||||
@ -66,6 +68,7 @@ async function login(options = {} as any): Promise<Page> {
|
||||
args: [
|
||||
'--no-sandbox',
|
||||
'--disable-setuid-sandbox',
|
||||
// `--proxy-server=${proxyUrl}`,
|
||||
]
|
||||
})
|
||||
log('创建新页面')
|
||||
|
@ -61,5 +61,30 @@ ipcMain.handle('gpt-batch-4.0', async (event, arg) => {
|
||||
})
|
||||
console.log('process', i, user, link)
|
||||
}
|
||||
browsers.forEach(browser => browser.close())
|
||||
// browsers.forEach(browser => browser.close())
|
||||
})
|
||||
|
||||
|
||||
const actions = {
|
||||
'gpt-link': getLink,
|
||||
'gpt-result': validate,
|
||||
'gpt-batch-4.0': batchApplication
|
||||
}
|
||||
|
||||
export async function runActions(action: keyof typeof actions, options: any) {
|
||||
const { text } = options
|
||||
const accounts = parseAccount(text)
|
||||
|
||||
const links = []
|
||||
for(let i = 0; i < accounts.length; i++) {
|
||||
const [user, pass] = accounts[i]
|
||||
const link = await batchApplication({ user, pass, index: i, id: user })
|
||||
links.push({
|
||||
i,
|
||||
user,
|
||||
link
|
||||
})
|
||||
console.log('process', i, user, link)
|
||||
}
|
||||
browsers.forEach(browser => browser.close())
|
||||
}
|
||||
|
@ -132,3 +132,31 @@ ipcMain.handle('stop', async (event, arg) => {
|
||||
return true
|
||||
})
|
||||
|
||||
|
||||
fetch("https://poe.com/api/gql_POST", {
|
||||
"headers": {
|
||||
"accept": "*/*",
|
||||
"accept-language": "zh-CN,zh;q=0.9",
|
||||
"content-type": "application/json",
|
||||
"poe-formkey": "520a133912dc68714f36a5bcf4848e59",
|
||||
"poe-tag-id": "0bc8018cd51c5229e87987cf31f8f89c",
|
||||
"poe-tchannel": "poe-chan49-8888-qcbwsgypbumznmwlcfwi",
|
||||
"sec-ch-ua": "\"Not.A/Brand\";v=\"8\", \"Chromium\";v=\"114\", \"Google Chrome\";v=\"114\"",
|
||||
"sec-ch-ua-mobile": "?0",
|
||||
"sec-ch-ua-platform": "\"macOS\"",
|
||||
"Cookie": "p-b=l9xRB8cUvzqnE5Wu0JoLCQ%3D%3D",
|
||||
"sec-fetch-dest": "empty",
|
||||
"sec-fetch-mode": "cors",
|
||||
"sec-fetch-site": "same-origin"
|
||||
},
|
||||
"referrer": "https://poe.com/zhenjie",
|
||||
"referrerPolicy": "strict-origin-when-cross-origin",
|
||||
"body": "{\"queryName\":\"chatHelpers_sendMessageMutation_Mutation\",\"variables\":{\"chatId\":15454343,\"bot\":\"zhenjie\",\"query\":\"hi\",\"source\":null,\"withChatBreak\":false,\"clientNonce\":\"eBAHfmO3h41BlXK0\",\"sdid\":\"36988d7a-8ed4-4eaa-bbf8-24782e5b5461\"},\"query\":\"mutation chatHelpers_sendMessageMutation_Mutation(\\n $chatId: BigInt!\\n $bot: String!\\n $query: String!\\n $source: MessageSource\\n $withChatBreak: Boolean!\\n $clientNonce: String\\n $sdid: String\\n) {\\n messageEdgeCreate(chatId: $chatId, bot: $bot, query: $query, source: $source, withChatBreak: $withChatBreak, clientNonce: $clientNonce, sdid: $sdid) {\\n chatBreak {\\n cursor\\n node {\\n id\\n messageId\\n text\\n author\\n suggestedReplies\\n creationTime\\n state\\n }\\n id\\n }\\n message {\\n cursor\\n node {\\n id\\n messageId\\n text\\n author\\n suggestedReplies\\n creationTime\\n state\\n clientNonce\\n contentType\\n chat {\\n shouldShowDisclaimer\\n id\\n }\\n }\\n id\\n }\\n bot {\\n id\\n messageLimit {\\n dailySent\\n }\\n }\\n status\\n }\\n}\\n\"}",
|
||||
"method": "POST",
|
||||
"mode": "cors",
|
||||
"credentials": "include"
|
||||
}).then(res => {
|
||||
console.log('ok', res)
|
||||
}).catch(err=> {
|
||||
console.log('err', err)
|
||||
})
|
||||
|
35
electron/main/login.ts
Normal file
35
electron/main/login.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import { clog } from './poe/login'
|
||||
import { browserAndPage } from './tools'
|
||||
|
||||
const login = {
|
||||
// poe 邮箱登录
|
||||
async poe_email(options) {
|
||||
const log = clog(options)
|
||||
|
||||
log('启动浏览器')
|
||||
|
||||
const { page } = await browserAndPage(options)
|
||||
|
||||
log('正在进入登录页面')
|
||||
await page.goto('https://poe.com/login')
|
||||
|
||||
log('设置登录方式')
|
||||
await page.evaluate((selector, searchText) => {
|
||||
const elements = Array.from(document.querySelectorAll(selector));
|
||||
const target = elements.find(el => el.textContent.trim() === searchText);
|
||||
|
||||
if (!target) return false
|
||||
|
||||
const text = target.nextElementSibling?.textContent || ''
|
||||
if (text.includes('email')) target.nextElementSibling.click()
|
||||
}, 'button', 'Go')
|
||||
|
||||
log('开始输入邮箱')
|
||||
await page.waitForSelector('input[type="email"]')
|
||||
await page.type('input[type="email"]', options.user)
|
||||
await page.keyboard.press('Enter')
|
||||
log('开始输入密码')
|
||||
}
|
||||
}
|
||||
|
||||
export default login
|
@ -2,6 +2,7 @@ import { getLink } from './getLink'
|
||||
import { validate } from './validate'
|
||||
import { ipcMain } from 'electron'
|
||||
import { browser } from './login'
|
||||
import { link_7day } from './link_7day'
|
||||
|
||||
// import './openBrowser'
|
||||
// suzzettedeanne2393@gmail.com----zebulonlawayne3013----zebulonlawayne4749@outlook.com
|
||||
@ -35,6 +36,29 @@ ipcMain.handle('getLink', async (event, arg) => {
|
||||
return links
|
||||
})
|
||||
|
||||
ipcMain.handle('get-poe-link-7day', async (event, arg) => {
|
||||
const { text } = arg
|
||||
const accounts = parseAccount(text)
|
||||
|
||||
const links = []
|
||||
for(let i = 0; i < accounts.length; i++) {
|
||||
const [user, pass, auxiliary] = accounts[i]
|
||||
const link = await link_7day({ user, pass, auxiliary, index: i, id: user })
|
||||
// .catch(err => {
|
||||
// console.log('error ->', err)
|
||||
// })
|
||||
links.push({
|
||||
i,
|
||||
user,
|
||||
link
|
||||
})
|
||||
console.log('process', i, user, link)
|
||||
}
|
||||
// browser && browser.close()
|
||||
return links
|
||||
})
|
||||
|
||||
|
||||
ipcMain.handle('poe-result', async (event, arg) => {
|
||||
const { text } = arg
|
||||
const accounts = parseAccount(text)
|
||||
|
50
electron/main/poe/link_7day.ts
Normal file
50
electron/main/poe/link_7day.ts
Normal file
@ -0,0 +1,50 @@
|
||||
import type { Browser, Page } from 'puppeteer'
|
||||
import puppeteer from 'puppeteer-extra'
|
||||
import StealthPlugin from 'puppeteer-extra-plugin-stealth'
|
||||
import { clog } from "./login"
|
||||
puppeteer.use(StealthPlugin())
|
||||
|
||||
async function login (options) {
|
||||
const log = clog(options)
|
||||
|
||||
log('启动浏览器')
|
||||
|
||||
const browser = await puppeteer.launch({
|
||||
headless: false,
|
||||
args: [
|
||||
'--no-sandbox',
|
||||
'--disable-setuid-sandbox',
|
||||
// `--proxy-server=http://192.168.1.80:7890`,
|
||||
]
|
||||
})
|
||||
|
||||
const page = await browser.newPage()
|
||||
await page.setExtraHTTPHeaders({
|
||||
'accept-language': 'en-US,en;q=0.9,hy;q=0.8'
|
||||
})
|
||||
|
||||
log('正在进入登录页面')
|
||||
await page.goto('https://poe.com/login')
|
||||
|
||||
log('设置登录方式')
|
||||
await page.evaluate((selector, searchText) => {
|
||||
const elements = Array.from(document.querySelectorAll(selector));
|
||||
const target = elements.find(el => el.textContent.trim() === searchText);
|
||||
|
||||
if (!target) return false
|
||||
|
||||
const text = target.nextElementSibling?.textContent || ''
|
||||
if (text.includes('email')) target.nextElementSibling.click()
|
||||
}, 'button', 'Go')
|
||||
|
||||
await page.waitForSelector('input[type="email"]')
|
||||
await page.type('input[type="email"]', options.user)
|
||||
await page.keyboard.press('Enter')
|
||||
|
||||
}
|
||||
|
||||
export async function link_7day (options) {
|
||||
const log = clog(options)
|
||||
log('开始', { ident: 'link_7day' })
|
||||
await login(options)
|
||||
}
|
@ -1,3 +1,7 @@
|
||||
import type { Page } from "puppeteer"
|
||||
import puppeteer from 'puppeteer-extra'
|
||||
import StealthPlugin from 'puppeteer-extra-plugin-stealth'
|
||||
puppeteer.use(StealthPlugin())
|
||||
|
||||
//生成从minNum到maxNum的随机数
|
||||
export function randomNum (min, max) {
|
||||
@ -10,3 +14,42 @@ export function awaitWrap<T, U = any>(promise: Promise<T>): Promise<[U | null, T
|
||||
.then<[null, T]>((data: T) => [null, data])
|
||||
.catch<[U, null]>(err => [err, null])
|
||||
}
|
||||
|
||||
// 设置页面请求
|
||||
export function pageRequest (page: Page) {
|
||||
page.on('request', (request) => {
|
||||
if (['stylesheet', 'font'].indexOf(request.resourceType()) !== -1) {
|
||||
request.abort()
|
||||
} else {
|
||||
request.continue()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const browsers = []
|
||||
|
||||
export async function browserAndPage (options) {
|
||||
const browser = await puppeteer.launch({
|
||||
headless: false,
|
||||
args: [
|
||||
'--no-sandbox',
|
||||
'--disable-setuid-sandbox',
|
||||
// `--proxy-server=http://
|
||||
]
|
||||
})
|
||||
const close = browser.close
|
||||
browser.close = async () => {
|
||||
let i = browsers.find(b => b === browser)
|
||||
await close()
|
||||
if (i !== -1) browsers.slice(i, 1)
|
||||
}
|
||||
|
||||
const page = await browser.newPage()
|
||||
await page.setExtraHTTPHeaders({
|
||||
'accept-language': 'en-US,en;q=0.9,hy;q=0.8'
|
||||
})
|
||||
|
||||
pageRequest(page)
|
||||
|
||||
return { browser, page }
|
||||
}
|
||||
|
18
src/App.vue
18
src/App.vue
@ -100,8 +100,6 @@ const list = ref<any[]>([
|
||||
])
|
||||
|
||||
ipcRenderer.on('progress', (event, args) => {
|
||||
console.log('progress', args);
|
||||
|
||||
const { user } = args
|
||||
const target = list.value.find((item) => item.user === user)
|
||||
|
||||
@ -118,6 +116,12 @@ function getLink(val?: string) {
|
||||
})
|
||||
}
|
||||
|
||||
function getLink_7day (val?: string) {
|
||||
ipcRenderer.invoke('get-poe-link-7day', { text: val || input.value }).then((res) => {
|
||||
console.log(res);
|
||||
})
|
||||
}
|
||||
|
||||
function getResult(val?: string) {
|
||||
ipcRenderer.invoke('poe-result', { text: val || input.value }).then((res) => {
|
||||
console.log(res);
|
||||
@ -155,6 +159,11 @@ function application () {
|
||||
ipcRenderer.invoke('gpt-batch-4.0', { text: input.value })
|
||||
}
|
||||
|
||||
// 申请结果
|
||||
function applicationResult () {
|
||||
ipcRenderer.invoke('gpt-batch-4.0-result', { text: input.value })
|
||||
}
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: '序列',
|
||||
@ -233,7 +242,12 @@ const columns = [
|
||||
<span w-15>poe:</span>
|
||||
<NButton type="primary" dashed @click="getLink()">提取链接</NButton>
|
||||
<NButton type="primary" dashed @click="getResult()">充值结果</NButton>
|
||||
<NButton type="primary" dashed @click="getLink_7day()">提取链接-7天</NButton>
|
||||
</div>
|
||||
<div flex gap-3 mt-3 items-center>
|
||||
<span w-15>gpt4.0:</span>
|
||||
<NButton type="primary" dashed @click="application()">申请4.0</NButton>
|
||||
<NButton type="primary" dashed @click="applicationResult()">检查申请结果(mail邮箱)</NButton>
|
||||
</div>
|
||||
<div flex gap-3 mt-3 items-center>
|
||||
<span w-15>gpt:</span>
|
||||
|
Loading…
x
Reference in New Issue
Block a user