feat(official_update): update to match new ak version

This commit is contained in:
Haoyu Xu
2024-05-02 13:14:40 +08:00
parent 1b782e0c7b
commit 314d0a4c7f
3 changed files with 182 additions and 144 deletions

View File

@@ -174,7 +174,7 @@ export default function Home() {
<section className={classes.content}>
<section className={classes.text}>{officalUpdate.length - operators.length} {i18n("new_op_wait_to_update")}</section>
<section className={`${classes['styled-selection']}`}>
{officalUpdate[officalUpdate.latest].map((entry, index) => {
{officalUpdate[officalUpdate.dates[0]].map((entry, index) => {
return (
<Link
reloadDocument

View File

@@ -31,53 +31,63 @@ export default class OfficalInfo {
const html_text = await f.text()
const dom = new jsdom.JSDOM(html_text);
const rows = dom.window.document.body.querySelector(".dynList").querySelectorAll(".row")
const scripts = dom.window.document.body.querySelectorAll("script");
let data;
scripts.forEach((e) => {
if (e.textContent.includes("干员晋升")) {
data = JSON.parse(e.textContent.replace("self.__next_f.push([1,\"c:", "").replace("\\n\"])", "").replaceAll("\\", ""))
}
})
const rows = data[0][3].initialData
const dict = {
length: 0
length: rows.length,
dates: []
}
let current_displayTime = rows[0].displayTime
let current_block = []
for (const row of rows) {
const date = row.querySelector(".date").textContent.trim()
const operators = []
const displayTime = row.displayTime
if (displayTime !== current_displayTime) {
dict[current_displayTime] = current_block;
dict.dates.push(current_displayTime);
current_displayTime = row.displayTime;
current_block = [];
}
current_block.push(this.get_row(row))
}
dict[current_displayTime] = current_block;
dict.dates.push(current_displayTime);
const charCards = row.querySelectorAll(".charCard")
if (dict.length === 0) {
dict.latest = date
}
for (const charCard of charCards) {
const color = charCard.style.color
const codename = {
"zh-CN": charCard.querySelector(".info").querySelector(".name").querySelector(".text").textContent.trim(),
"en-US": charCard.querySelector(".info").querySelector(".codename").textContent.trim()
}
const rawType = charCard.querySelector(".typeIcon").querySelector("svg").querySelector("use").getAttribute("xlink:href")
const link = "https://ak.hypergryph.com" + charCard.getAttribute("href")
const linkSplited = link.split("/")
const id = linkSplited[linkSplited.length - 1].replace(".html", "")
let type;
switch (rawType) {
case "#skin-type-icon-hanger":
type = "skin"
break;
case "#skin-type-icon-promotion2":
type = "operator"
break;
}
operators.push({
color,
codename,
type,
link,
id
})
dict.length++
}
dict[date] = operators
}
writeSync(JSON.stringify(dict, null, 4), path.join('offical_update.json'))
}
get_row(row) {
const type = row.type;
let codename_zhCN, item_type;
switch (type) {
case 0:
codename_zhCN = row.charName
item_type = "operator"
break;
case 1:
codename_zhCN = row.suitName + " · " + row.charName
item_type = "skin"
break;
default:
throw ("unknown type");
}
return {
color: null,
codename: {
"zh-CN": codename_zhCN,
"en-US": row.codename
},
type: item_type,
link: `https://ak.hypergryph.com/archive/dynamicCompile/${row.cid}.html`,
id: row.cid
}
}
}

View File

@@ -1,9 +1,35 @@
{
"length": 45,
"latest": "2024/05",
"2024/05": [
"dates": [
"2024-05-01",
"2024-04-01",
"2024-02-29",
"2024-02-28",
"2024-01-01",
"2023-11-01",
"2023-08-01",
"2023-07-01",
"2023-04-01",
"2023-02-01",
"2023-01-01",
"2022-12-15",
"2022-11-01",
"2022-10-01",
"2022-08-01",
"2022-05-01",
"2022-04-30",
"2022-01-01",
"2021-11-01",
"2021-08-01",
"2021-05-01",
"2021-02-01",
"2020-11-01",
"2020-05-01",
"2020-01-01"
],
"2024-05-01": [
{
"color": "rgb(210, 14, 16)",
"color": null,
"codename": {
"zh-CN": "维什戴尔",
"en-US": "WISADEL"
@@ -13,27 +39,27 @@
"id": "202404049"
},
{
"color": "rgb(18, 185, 187)",
"color": null,
"codename": {
"zh-CN": "新枝 · 缪尔赛思",
"en-US": "MUELSYSE"
"en-US": "Muelsyse"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202404090.html",
"id": "202404090"
},
{
"color": "rgb(232, 0, 0)",
"color": null,
"codename": {
"zh-CN": "红女爵 · 浊心斯卡蒂",
"en-US": "RED COUNTESS"
"en-US": "Red Countess"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202404008.html",
"id": "202404008"
},
{
"color": "rgb(164, 1, 1)",
"color": null,
"codename": {
"zh-CN": "燃烧天穹下 · 伊内丝",
"en-US": "INES"
@@ -43,305 +69,307 @@
"id": "202404087"
}
],
"2024/04": [
"2024-04-01": [
{
"color": "rgb(45, 155, 203)",
"color": null,
"codename": {
"zh-CN": "不融冰 · 银灰",
"en-US": "NEVER-MELTING ICE"
"en-US": "Never-melting Ice"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202404066.html",
"id": "202404066"
}
],
"2024/02": [
"2024-02-29": [
{
"color": "rgb(34, 187, 255)",
"color": null,
"codename": {
"zh-CN": "黍",
"en-US": "SHU"
"en-US": "shu"
},
"type": "operator",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202401025.html",
"id": "202401025"
},
{
"color": "rgb(174, 216, 236)",
"color": null,
"codename": {
"zh-CN": "列瑶台 · 林",
"en-US": "HEAVENLY MIRAGE"
"en-US": "Heavenly Mirage"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202401034.html",
"id": "202401034"
},
}
],
"2024-02-28": [
{
"color": "rgb(187, 109, 22)",
"color": null,
"codename": {
"zh-CN": "何处栖 · 重岳",
"en-US": "ALIGHTING"
"en-US": "Alighting"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202401812.html",
"id": "202401812"
}
],
"2024/01": [
"2024-01-01": [
{
"color": "rgb(228, 183, 19)",
"color": null,
"codename": {
"zh-CN": "博物 · 焰影苇草",
"en-US": "CURATOR"
"en-US": "Curator"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202401871.html",
"id": "202401871"
}
],
"2023/11": [
"2023-11-01": [
{
"color": "rgb(189, 103, 7)",
"color": null,
"codename": {
"zh-CN": "塑心",
"en-US": "VIRTUOSA"
"en-US": "Virtuosa"
},
"type": "operator",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202310848.html",
"id": "202310848"
},
{
"color": "rgb(51, 63, 115)",
"color": null,
"codename": {
"zh-CN": "远路 · 玛恩纳",
"en-US": "W DALI"
"en-US": "W Dali"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202310850.html",
"id": "202310850"
},
{
"color": "rgb(222, 2, 7)",
"color": null,
"codename": {
"zh-CN": "破翼者 · 缄默德克萨斯",
"en-US": "WINGBREAKER"
"en-US": "Wingbreaker"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202310899.html",
"id": "202310899"
}
],
"2023/08": [
"2023-08-01": [
{
"color": "rgb(183, 227, 243)",
"color": null,
"codename": {
"zh-CN": "崖高梦远 · 令",
"en-US": "TOWERING IS CLIFF OF NOSTALGIA"
"en-US": "Towering is cliff of nostalgia"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202308807.html",
"id": "202308807"
}
],
"2023/07": [
"2023-07-01": [
{
"color": "rgb(163, 220, 247)",
"color": null,
"codename": {
"zh-CN": "悠然假日 HD26 · 百炼嘉维尔",
"en-US": "GAVIAL THE INVINCIBLE HD26"
"en-US": "Gavial the Invincible HD26"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202307886.html",
"id": "202307886"
},
{
"color": "rgb(34, 187, 255)",
"color": null,
"codename": {
"zh-CN": "纯烬艾雅法拉",
"en-US": "EYJAFJALLA THE HVÍT ASKA"
"en-US": "Eyjafjalla the Hvít Aska"
},
"type": "operator",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202307865.html",
"id": "202307865"
},
{
"color": "rgba(253, 188, 208, 0.97)",
"color": null,
"codename": {
"zh-CN": "夏卉 FA394 · 澄闪",
"en-US": "SUMMER FLOWERS FA394"
"en-US": "Summer Flowers FA394"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202307824.html",
"id": "202307824"
}
],
"2023/04": [
"2023-04-01": [
{
"color": "rgb(118, 165, 185)",
"color": null,
"codename": {
"zh-CN": "残余 · 凯尔希",
"en-US": "REMNANT"
"en-US": "Remnant"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202304833.html",
"id": "202304833"
},
{
"color": "rgb(146, 212, 143)",
"color": null,
"codename": {
"zh-CN": "缪尔赛思",
"en-US": "MUELSYSE"
"en-US": "Muelsyse"
},
"type": "operator",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202304611.html",
"id": "202304611"
},
{
"color": "rgb(140, 7, 7)",
"color": null,
"codename": {
"zh-CN": "生而为一 · 归溟幽灵鲨",
"en-US": "BORN AS ONE"
"en-US": "Born as One"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202304670.html",
"id": "202304670"
},
{
"color": "rgb(6, 34, 129)",
"color": null,
"codename": {
"zh-CN": "万重山 · 假日威龙陈",
"en-US": "TEN THOUSAND MOUNTAINS"
"en-US": "Ten Thousand Mountains"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202304659.html",
"id": "202304659"
}
],
"2023/02": [
"2023-02-01": [
{
"color": "rgb(145, 220, 253)",
"color": null,
"codename": {
"zh-CN": "字句中的雪原 · 鸿雪",
"en-US": "SNOWY PLAINS IN WORDS"
"en-US": "Snowy Plains in Words"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202302698.html",
"id": "202302698"
}
],
"2023/01": [
"2023-01-01": [
{
"color": "rgb(255, 133, 34)",
"color": null,
"codename": {
"zh-CN": "重岳",
"en-US": "CHONGYUE"
"en-US": "Chongyue"
},
"type": "operator",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202301606.html",
"id": "202301606"
},
{
"color": "rgb(37, 148, 197)",
"color": null,
"codename": {
"zh-CN": "濯缨 · 令",
"en-US": "IT DOES WASH THE STRINGS"
"en-US": "It Does Wash the Strings"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202301647.html",
"id": "202301647"
}
],
"2022/12": [
"2022-12-15": [
{
"color": "rgb(156, 210, 246)",
"color": null,
"codename": {
"zh-CN": "夏日餮宴 · 水月",
"en-US": "SUMMER FEAST"
"en-US": "Summer Feast"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202211685.html",
"id": "202211685"
}
],
"2022/11": [
"2022-11-01": [
{
"color": "rgba(34, 37, 255, 0.9)",
"color": null,
"codename": {
"zh-CN": "缄默德克萨斯",
"en-US": "TEXAS THE OMERTOSA"
"en-US": "Texas the Omertosa"
},
"type": "operator",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202210210.html",
"id": "202210210"
},
{
"color": "rgb(231, 166, 144)",
"color": null,
"codename": {
"zh-CN": "今昔须臾之梦 · 异客",
"en-US": "DREAM IN A MOMENT"
"en-US": "Dream in a Moment"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202210664.html",
"id": "202210664"
},
{
"color": "rgb(141, 213, 228)",
"color": null,
"codename": {
"zh-CN": "复现荣光 · 耀骑士临光",
"en-US": "RELIGHT"
"en-US": "Relight"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202210623.html",
"id": "202210623"
},
{
"color": "rgb(116, 177, 222)",
"color": null,
"codename": {
"zh-CN": "拥抱新生 · 迷迭香",
"en-US": "BECOME ANEW"
"en-US": "Become Anew"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202210632.html",
"id": "202210632"
}
],
"2022/10": [
"2022-10-01": [
{
"color": "rgb(206, 0, 0)",
"color": null,
"codename": {
"zh-CN": "手到牌来 · 老鲤",
"en-US": "TRUST YOUR EYES"
"en-US": "Trust Your Eyes"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202210279.html",
"id": "202210279"
}
],
"2022/08": [
"2022-08-01": [
{
"color": "rgb(29, 185, 53)",
"color": null,
"codename": {
"zh-CN": "百炼嘉维尔 ",
"en-US": "GAVIAL THE INVINCIBLE"
"en-US": "Gavial the Invincible"
},
"type": "operator",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202208258.html",
"id": "202208258"
},
{
"color": "rgb(177, 226, 249)",
"color": null,
"codename": {
"zh-CN": "缤纷奇境 CW03 · 史尔特尔",
"en-US": "COLORFUL WONDERLAND CW03"
"en-US": "Colorful Wonderland CW03"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202208297.html",
"id": "202208297"
}
],
"2022/05": [
"2022-05-01": [
{
"color": "rgba(14, 124, 203, 0.86)",
"color": null,
"codename": {
"zh-CN": "归溟幽灵鲨",
"en-US": "SPECTER THE UNCHAINED"
@@ -351,7 +379,7 @@
"id": "202204284"
},
{
"color": "rgba(95, 116, 187, 0.74)",
"color": null,
"codename": {
"zh-CN": "升华 · 浊心斯卡蒂",
"en-US": "SUBLIMATION"
@@ -361,9 +389,9 @@
"id": "202204205"
}
],
"2022/04": [
"2022-04-30": [
{
"color": "rgb(158, 2, 2)",
"color": null,
"codename": {
"zh-CN": "焦点 · 傀影",
"en-US": "FOCUS"
@@ -373,9 +401,9 @@
"id": "202203222"
}
],
"2022/01": [
"2022-01-01": [
{
"color": "rgb(15, 206, 216)",
"color": null,
"codename": {
"zh-CN": "令",
"en-US": "LING"
@@ -385,7 +413,7 @@
"id": "20220383"
},
{
"color": "rgb(78, 201, 187)",
"color": null,
"codename": {
"zh-CN": "染尘烟 · 夕",
"en-US": "EVERYTHING IS A MIRACLE"
@@ -395,9 +423,9 @@
"id": "20220321"
}
],
"2021/11": [
"2021-11-01": [
{
"color": "rgba(253, 236, 189, 0.95)",
"color": null,
"codename": {
"zh-CN": "耀骑士临光",
"en-US": "NEARL THE RADIANT KNIGHT"
@@ -407,21 +435,21 @@
"id": "20220304"
}
],
"2021/08": [
"2021-08-01": [
{
"color": "rgba(14, 126, 239, 0.85)",
"color": null,
"codename": {
"zh-CN": "假日威龙陈",
"en-US": "CH'EN THE HOLUNGDAY"
"en-US": "Ch'en the Holungday"
},
"type": "operator",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/20220345.html",
"id": "20220345"
}
],
"2021/05": [
"2021-05-01": [
{
"color": "rgb(226, 96, 96)",
"color": null,
"codename": {
"zh-CN": "浊心斯卡蒂",
"en-US": "SKADI THE CORRUPTING HEART"
@@ -431,9 +459,9 @@
"id": "20220396"
}
],
"2021/02": [
"2021-02-01": [
{
"color": "rgb(9, 212, 208)",
"color": null,
"codename": {
"zh-CN": "夕",
"en-US": "DUSK"
@@ -443,7 +471,7 @@
"id": "202203263"
},
{
"color": "rgb(187, 163, 106)",
"color": null,
"codename": {
"zh-CN": "乐逍遥 · 年",
"en-US": "UNFETTERED FREEDOM"
@@ -453,9 +481,9 @@
"id": "20220362"
}
],
"2020/11": [
"2020-11-01": [
{
"color": "rgb(23, 210, 236)",
"color": null,
"codename": {
"zh-CN": "迷迭香",
"en-US": "ROSMONTIS"
@@ -465,19 +493,19 @@
"id": "20220378"
},
{
"color": "rgba(0, 0, 0, 0.83)",
"color": null,
"codename": {
"zh-CN": "恍惚 · W",
"en-US": "WONDER"
"en-US": "Wonder"
},
"type": "skin",
"link": "https://ak.hypergryph.com/archive/dynamicCompile/202206246.html",
"id": "202206246"
}
],
"2020/05": [
"2020-05-01": [
{
"color": "rgb(228, 54, 56)",
"color": null,
"codename": {
"zh-CN": "W",
"en-US": "W"
@@ -487,9 +515,9 @@
"id": "20220319"
}
],
"2020/01": [
"2020-01-01": [
{
"color": "rgb(255, 48, 0)",
"color": null,
"codename": {
"zh-CN": "年",
"en-US": "NIAN"