mirror of
				https://github.com/shufflewzc/faker2.git
				synced 2025-11-04 15:22:47 +08:00 
			
		
		
		
	Update TS_USER_AGENTS.ts
This commit is contained in:
		
							parent
							
								
									c5c18cf7ff
								
							
						
					
					
						commit
						5b95f56ecf
					
				@ -5,7 +5,10 @@ import {existsSync, readFileSync} from "fs"
 | 
			
		||||
import {sendNotify} from './sendNotify'
 | 
			
		||||
 | 
			
		||||
dotenv.config()
 | 
			
		||||
const USER_AGENTS_ARR: string[] = [
 | 
			
		||||
 | 
			
		||||
let fingerprint: string | number, token: string = '', enCryptMethodJD: any
 | 
			
		||||
 | 
			
		||||
const USER_AGENTS: Array<string> = [
 | 
			
		||||
  "jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; ONEPLUS A5010 Build/QKQ1.191014.012; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36",
 | 
			
		||||
  "jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
 | 
			
		||||
  "jdapp;android;10.0.2;9;network/4g;Mozilla/5.0 (Linux; Android 9; Mi Note 3 Build/PKQ1.181007.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045131 Mobile Safari/537.36",
 | 
			
		||||
@ -44,12 +47,20 @@ const USER_AGENTS_ARR: string[] = [
 | 
			
		||||
  "jdapp;iPhone;10.0.2;14.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
function TotalBean(cookie: string) {
 | 
			
		||||
  return {
 | 
			
		||||
    cookie: cookie,
 | 
			
		||||
    isLogin: true,
 | 
			
		||||
    nickName: ''
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function getRandomNumberByRange(start: number, end: number) {
 | 
			
		||||
  end <= start && (end = start + 100)
 | 
			
		||||
  return Math.floor(Math.random() * (end - start) + start)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
let USER_AGENT = USER_AGENTS_ARR[getRandomNumberByRange(0, USER_AGENTS_ARR.length)]
 | 
			
		||||
let USER_AGENT = USER_AGENTS[getRandomNumberByRange(0, USER_AGENTS.length)]
 | 
			
		||||
 | 
			
		||||
async function getBeanShareCode(cookie: string) {
 | 
			
		||||
  let {data}: any = await axios.post('https://api.m.jd.com/client.action',
 | 
			
		||||
@ -87,18 +98,14 @@ async function getFarmShareCode(cookie: string) {
 | 
			
		||||
    return ''
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function getCookie(check: boolean = false): Promise<string[]> {
 | 
			
		||||
  let pwd: string = __dirname
 | 
			
		||||
async function requireConfig(check: boolean = false): Promise<string[]> {
 | 
			
		||||
  let cookiesArr: string[] = []
 | 
			
		||||
  const jdCookieNode = require('./jdCookie.js')
 | 
			
		||||
  let keys: string[] = Object.keys(jdCookieNode)
 | 
			
		||||
  for (let i = 0; i < keys.length; i++) {
 | 
			
		||||
    let cookie = jdCookieNode[keys[i]]
 | 
			
		||||
    if (!check) {
 | 
			
		||||
      if (pwd.includes('/ql') && !pwd.includes('JDHelloWorld')) {
 | 
			
		||||
      } else {
 | 
			
		||||
        cookiesArr.push(cookie)
 | 
			
		||||
      }
 | 
			
		||||
      cookiesArr.push(cookie)
 | 
			
		||||
    } else {
 | 
			
		||||
      if (await checkCookie(cookie)) {
 | 
			
		||||
        cookiesArr.push(cookie)
 | 
			
		||||
@ -131,12 +138,59 @@ async function checkCookie(cookie: string) {
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function wait(ms: number) {
 | 
			
		||||
function wait(timeout: number) {
 | 
			
		||||
  return new Promise(resolve => {
 | 
			
		||||
    setTimeout(resolve, ms)
 | 
			
		||||
    setTimeout(resolve, timeout)
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function requestAlgo(appId: number = 10032) {
 | 
			
		||||
  fingerprint = generateFp()
 | 
			
		||||
  return new Promise<void>(async resolve => {
 | 
			
		||||
    let {data}: any = await axios.post('https://cactus.jd.com/request_algo?g_ty=ajax', {
 | 
			
		||||
      "version": "1.0",
 | 
			
		||||
      "fp": fingerprint,
 | 
			
		||||
      "appId": appId,
 | 
			
		||||
      "timestamp": Date.now(),
 | 
			
		||||
      "platform": "web",
 | 
			
		||||
      "expandParams": ""
 | 
			
		||||
    }, {
 | 
			
		||||
      "headers": {
 | 
			
		||||
        'Authority': 'cactus.jd.com',
 | 
			
		||||
        'Pragma': 'no-cache',
 | 
			
		||||
        'Cache-Control': 'no-cache',
 | 
			
		||||
        'Accept': 'application/json',
 | 
			
		||||
        'User-Agent': USER_AGENT,
 | 
			
		||||
        'Content-Type': 'application/json',
 | 
			
		||||
        'Origin': 'https://st.jingxi.com',
 | 
			
		||||
        'Sec-Fetch-Site': 'cross-site',
 | 
			
		||||
        'Sec-Fetch-Mode': 'cors',
 | 
			
		||||
        'Sec-Fetch-Dest': 'empty',
 | 
			
		||||
        'Referer': 'https://st.jingxi.com/',
 | 
			
		||||
        'Accept-Language': 'zh-CN,zh;q=0.9,zh-TW;q=0.8,en;q=0.7'
 | 
			
		||||
      },
 | 
			
		||||
    })
 | 
			
		||||
    if (data['status'] === 200) {
 | 
			
		||||
      token = data.data.result.tk
 | 
			
		||||
      let enCryptMethodJDString = data.data.result.algo
 | 
			
		||||
      if (enCryptMethodJDString) enCryptMethodJD = new Function(`return ${enCryptMethodJDString}`)()
 | 
			
		||||
    } else {
 | 
			
		||||
      console.log(`fp: ${fingerprint}`)
 | 
			
		||||
      console.log('request_algo 签名参数API请求失败:')
 | 
			
		||||
    }
 | 
			
		||||
    resolve()
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function generateFp() {
 | 
			
		||||
  let e = "0123456789"
 | 
			
		||||
  let a = 13
 | 
			
		||||
  let i = ''
 | 
			
		||||
  for (; a--;)
 | 
			
		||||
    i += e[Math.random() * e.length | 0]
 | 
			
		||||
  return (i + Date.now()).slice(0, 16)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function getJxToken(cookie: string, phoneId: string = '') {
 | 
			
		||||
  function generateStr(input: number) {
 | 
			
		||||
    let src = 'abcdefghijklmnopqrstuvwxyz1234567890'
 | 
			
		||||
@ -235,8 +289,7 @@ async function getShareCodePool(key: string, num: number) {
 | 
			
		||||
  return shareCode
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
async function wechat_app_msg(title: string, content: string, user: string) {
 | 
			
		||||
/*async function wechat_app_msg(title: string, content: string, user: string) {
 | 
			
		||||
  let corpid: string = "", corpsecret: string = ""
 | 
			
		||||
  let {data: gettoken} = await axios.get(`https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=${corpid}&corpsecret=${corpsecret}`)
 | 
			
		||||
  let access_token: string = gettoken.access_token
 | 
			
		||||
@ -255,8 +308,11 @@ async function wechat_app_msg(title: string, content: string, user: string) {
 | 
			
		||||
  } else {
 | 
			
		||||
    console.log('企业微信应用消息发送失败', send)
 | 
			
		||||
  }
 | 
			
		||||
}*/
 | 
			
		||||
 | 
			
		||||
function obj2str(obj: object) {
 | 
			
		||||
  return JSON.stringify(obj)
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
async function getDevice() {
 | 
			
		||||
  let {data} = await axios.get('https://betahub.cn/api/apple/devices/iPhone', {
 | 
			
		||||
@ -321,11 +377,13 @@ function post(url: string, prarms?: string | object, headers?: any): Promise<any
 | 
			
		||||
 | 
			
		||||
export default USER_AGENT
 | 
			
		||||
export {
 | 
			
		||||
  TotalBean,
 | 
			
		||||
  getBeanShareCode,
 | 
			
		||||
  getFarmShareCode,
 | 
			
		||||
  getCookie,
 | 
			
		||||
  requireConfig,
 | 
			
		||||
  wait,
 | 
			
		||||
  getRandomNumberByRange,
 | 
			
		||||
  requestAlgo,
 | 
			
		||||
  getJxToken,
 | 
			
		||||
  exceptCookie,
 | 
			
		||||
  randomString,
 | 
			
		||||
@ -334,8 +392,8 @@ export {
 | 
			
		||||
  getshareCodeHW,
 | 
			
		||||
  getShareCodePool,
 | 
			
		||||
  randomWord,
 | 
			
		||||
  obj2str,
 | 
			
		||||
  jdpingou,
 | 
			
		||||
  get,
 | 
			
		||||
  post,
 | 
			
		||||
  USER_AGENTS_ARR
 | 
			
		||||
  post
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user