From b3c2ffd3fa5b9361683f6d60e929410441c01681 Mon Sep 17 00:00:00 2001 From: woohoo Date: Sat, 8 Jan 2022 17:36:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E2=80=9CFlexible=20?= =?UTF-8?q?Body=20Armor=E2=80=9D=E7=9A=84=E7=89=A9=E5=93=81=E5=90=8D?= =?UTF-8?q?=E7=BF=BB=E8=AF=91=20=E5=A2=9E=E5=8A=A0=E4=BA=86=E9=A3=9E?= =?UTF-8?q?=E8=8A=B1=E5=BA=93=E5=AD=98=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fstock.py | 104 ++++++++++++++++++++++++++++++++++++++++ torn-trans-zhcn.user.js | 24 ++++++++-- 2 files changed, 124 insertions(+), 4 deletions(-) create mode 100644 fstock.py diff --git a/fstock.py b/fstock.py new file mode 100644 index 0000000..9107efe --- /dev/null +++ b/fstock.py @@ -0,0 +1,104 @@ +from datetime import datetime,timezone,timedelta + +import requests + +url = "https://yata.yt/api/v1/travel/export/" +resObj = requests.get(url).json() + +tzutc_8 = timezone(timedelta(hours=8)) +lastUpdate = 0 +dest_arr = ['mex', 'cay', 'can', 'haw', 'uni', 'arg', 'swi', 'jap', 'chi', 'uae', 'sou'] +for dest in dest_arr: + res_update = resObj["stocks"][dest]["update"] + if lastUpdate < res_update: + lastUpdate = res_update +lastUpdate = datetime.fromtimestamp(lastUpdate).astimezone(tzutc_8) +seq = ["最后更新 %s\n" % lastUpdate.strftime('%H:%M:%S')] + +mexStock = {} +for stock in resObj["stocks"]["mex"]["stocks"]: + if "Dahlia" == stock["name"]: + mexStock["hua"] = stock["quantity"] + if "Jaguar Plushie" == stock["name"]: + mexStock["ou"] = stock["quantity"] +seq.append("墨 花%s 偶%s\n" % (mexStock["hua"], mexStock["ou"])) +cayStock = {} +for stock in resObj["stocks"]["cay"]["stocks"]: + if "Banana Orchid" == stock["name"]: + cayStock["hua"] = stock["quantity"] + if "Stingray Plushie" == stock["name"]: + cayStock["ou"] = stock["quantity"] +seq.append("开 花%s 偶%s\n" % (cayStock["hua"], cayStock["ou"])) +canStock = {} +for stock in resObj["stocks"]["can"]["stocks"]: + if "Crocus" == stock["name"]: + canStock["hua"] = stock["quantity"] + if "Wolverine Plushie" == stock["name"]: + canStock["ou"] = stock["quantity"] +seq.append("加 花%s 偶%s\n" % (canStock["hua"], canStock["ou"])) +hawStock = {} +for stock in resObj["stocks"]["haw"]["stocks"]: + if "Orchid" == stock["name"]: + hawStock["hua"] = stock["quantity"] + if "Large Suitcase" == stock["name"]: + hawStock["xiang"] = stock["quantity"] +seq.append("夏 花%s 箱%s\n" % (hawStock["hua"], hawStock["xiang"])) +ukStock = {} +for stock in resObj["stocks"]["uni"]["stocks"]: + if "Red Fox Plushie" == stock["name"]: + ukStock["Red"] = stock["quantity"] + if "Nessie Plushie" == stock["name"]: + ukStock["Nessie"] = stock["quantity"] + if "Heather" == stock["name"]: + ukStock["Heather"] = stock["quantity"] +seq.append("嘤 赤狐%s 水怪%s 花%s\n" % (ukStock["Red"], ukStock["Nessie"], ukStock["Heather"])) +agtStock = {} +for stock in resObj["stocks"]["arg"]["stocks"]: + if "Ceibo Flower" == stock["name"]: + agtStock["hua"] = stock["quantity"] + if "Monkey Plushie" == stock["name"]: + agtStock["ou"] = stock["quantity"] + if "Tear Gas" == stock["name"]: + agtStock["tear"] = stock["quantity"] +seq.append("阿 花%s 偶%s 雷%s\n" % (agtStock["hua"], agtStock["ou"], agtStock["tear"])) +swiStock = {} +for stock in resObj["stocks"]["swi"]["stocks"]: + if "Chamois Plushie" == stock["name"]: + swiStock["ou"] = stock["quantity"] + if "Edelweiss" == stock["name"]: + swiStock["hua"] = stock["quantity"] +seq.append("瑞 花%s 偶%s\n" % (swiStock["hua"], swiStock["ou"])) +jpStock = {} +for stock in resObj["stocks"]["jap"]["stocks"]: + if "Cherry Blossom" == stock["name"]: + jpStock["hua"] = stock["quantity"] +seq.append("日 花%s\n" % jpStock["hua"]) +zgStock = {} +for stock in resObj["stocks"]["chi"]["stocks"]: + if "Panda Plushie" == stock["name"]: + zgStock["ou"] = stock["quantity"] + if "Peony" == stock["name"]: + zgStock["hua"] = stock["quantity"] +seq.append("中 花%s 偶%s\n" % (zgStock["hua"], zgStock["ou"])) +uaeStock = {} +for stock in resObj["stocks"]["uae"]["stocks"]: + if "Camel Plushie" == stock["name"]: + uaeStock["ou"] = stock["quantity"] + if "Tribulus Omanense" == stock["name"]: + uaeStock["hua"] = stock["quantity"] +seq.append("迪 花%s 偶%s\n" % (uaeStock["hua"], uaeStock["ou"])) +nfStock = {} +for stock in resObj["stocks"]["sou"]["stocks"]: + if "Lion Plushie" == stock["name"]: + nfStock["ou"] = stock["quantity"] + if "African Violet" == stock["name"]: + nfStock["hua"] = stock["quantity"] + if "Xanax" == stock["name"]: + nfStock["xan"] = stock["quantity"] +seq.append("南 花%s 偶%s XAN%s" % (nfStock["hua"], nfStock["ou"], nfStock["xan"])) + +fo = open(file="stock.txt", mode="w", encoding="utf-8") +fo.writelines(seq) +fo.close() + +print("花偶库存txt更新完成") diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js index d0991f5..c28222b 100644 --- a/torn-trans-zhcn.user.js +++ b/torn-trans-zhcn.user.js @@ -1,8 +1,8 @@ // ==UserScript== -// @lastmodified 202201071742 +// @lastmodified 202201081736 // @name Torn翻译 // @namespace WOOH -// @version 0.2.0107a +// @version 0.2.0108a // @description Torn UI翻译 // @author Woohoo-[2687093] sabrina_devil[2696209] // @match https://www.torn.com/* @@ -15,13 +15,19 @@ ___window___.WHTRANS = true; const CC_set = /[\u4e00-\u9fa5]/; - const version = '0.2.0107a'; + const version = '0.2.0108a'; const changelist = [ { todo: true, cont: `翻译:baza npc商店、imarket、imarket搜索结果`, }, + { + ver: '0.2.0108a', + date: '20220108', + cont: `修改了“Flexible Body Armor”的物品名翻译 +增加了飞花库存图`, + }, { ver: '0.2.0107a', date: '20220107', @@ -1755,7 +1761,7 @@ "Combat Helmet": '战斗头盔', "Combat Vest": '战斗背心', "Liquid Body Armor": '液体防弹衣', - "Flexible Body Armor": '活动防弹衣', + "Flexible Body Armor": '弹性防弹衣', "Medieval Helmet": '中世纪头盔', "Motorcycle Helmet": '摩托车头盔', "Welding Helmet": '电焊头盔', @@ -3085,6 +3091,16 @@ ], dictName: 'quickFinishAtt', }, + { + domType: 'button', + domId: 'wh-foreign-stock-btn', + domText: '飞花库存', + clickFunc: function (e) { + e.target.blur(); + const insert = `stock.png`; + popupMsg(insert, '飞花库存'); + }, + }, { domType: 'checkbox', domId: 'wh-dev-mode',