Skip to content

Commit

Permalink
feat: add api flag to avoid breaking official websites
Browse files Browse the repository at this point in the history
  • Loading branch information
daidr committed Oct 3, 2022
1 parent 524dde3 commit 0444921
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ const writeDataToStorage = async function <T>(key: string, data: T) {
}

const targetPages = [
'https://api-os-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie*',
'https://api-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie*',
'https://bbs-api-os.hoyolab.com/game_record/app/genshin/api/dailyNote*',
'https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/dailyNote*',
'https://api-os-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie?game_biz=hk4e_global&asource=paimon',
'https://api-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie?game_biz=hk4e_cn&asource=paimon',
'https://bbs-api-os.hoyolab.com/game_record/app/genshin/api/dailyNote?asource=paimon*',
'https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/dailyNote?asource=paimon*',
]

let currentCookie = ''
Expand Down
5 changes: 3 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ function getHeader(oversea: boolean, params: Record<string, string>, body: objec
async function getRoleInfoByCookie(oversea: boolean, cookie: string, setCookie?: Function): Promise<IRoleDataItem[] | false> {
// 根据 oversea 参数选择对应 api 地址
const url = oversea
? 'https://api-os-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie?game_biz=hk4e_global'
: 'https://api-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie?game_biz=hk4e_cn'
? 'https://api-os-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie?game_biz=hk4e_global&asource=paimon'
: 'https://api-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie?game_biz=hk4e_cn&asource=paimon'

// 生成 header
const headers = getHeader(oversea, {}, {}, false)
Expand Down Expand Up @@ -398,6 +398,7 @@ async function getRoleDataByCookie(oversea: boolean, cookie: string, role_id: st
const params = {
server: serverRegion,
role_id,
asource: 'paimon',
}

for (const [key, value] of Object.entries(params))
Expand Down

0 comments on commit 0444921

Please sign in to comment.