Skip to content

Commit

Permalink
perf: wbi 签名优先使用本地存储
Browse files Browse the repository at this point in the history
  • Loading branch information
Howard20181 committed Dec 26, 2023
1 parent dc05b35 commit 64e5f82
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions extensions/area_unlimit/hook/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -2022,15 +2022,24 @@ const UTILS = {

// 获取最新的 img_key 和 sub_key
async getWbiKeys() {
const SESSDATA = await cookieStore.get('SESSDATA') || {}
const res = await fetch('https://api.bilibili.com/x/web-interface/nav', {
headers: {
// SESSDATA 字段
Cookie: `SESSDATA=${SESSDATA?.value}`
}
})
const { data: { wbi_img: { img_url, sub_url } } } = await res.json()

let img_url, sub_url, wbi_img
const wbi_img_urls = localStorage.wbi_img_urls
if (wbi_img_urls) {
wbi_img = wbi_img_urls.split('-')
img_url = wbi_img[0]
sub_url = wbi_img[1]
} else {
const SESSDATA = await cookieStore.get('SESSDATA') || {}
const res = await fetch('https://api.bilibili.com/x/web-interface/nav', {
headers: {
Cookie: `SESSDATA=${SESSDATA?.value}`
}
})
const json = await res.json()
wbi_img = json.data.wbi_img
img_url = wbi_img.img_url
sub_url = wbi_img.sub_url
}
return {
img_key: img_url.slice(
img_url.lastIndexOf('/') + 1,
Expand Down

0 comments on commit 64e5f82

Please sign in to comment.