调整飞行闹钟的样式
This commit is contained in:
parent
2149eb30a0
commit
ca9665ca72
186
fstock.py
186
fstock.py
@ -1,19 +1,15 @@
|
||||
import json
|
||||
from datetime import datetime, timezone, timedelta
|
||||
from copy import deepcopy
|
||||
import os
|
||||
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']
|
||||
dest_trans_dict = {
|
||||
DEST_ARR = ['mex', 'cay', 'can', 'haw', 'uni', 'arg', 'swi', 'jap', 'chi', 'uae', 'sou']
|
||||
DEST_TRANS = {
|
||||
'mex': '墨', 'cay': '开', 'can': '加',
|
||||
'haw': '夏', 'uni': '嘤', 'arg': '阿',
|
||||
'swi': '瑞', 'jap': '日', 'chi': '中', 'uae': '迪', 'sou': '南',
|
||||
}
|
||||
valued_item = [
|
||||
VALUED_ITEM_ARR = [
|
||||
'Dahlia', 'Jaguar Plushie',
|
||||
'Banana Orchid', 'Stingray Plushie',
|
||||
'Crocus', 'Wolverine Plushie',
|
||||
@ -26,7 +22,7 @@ valued_item = [
|
||||
'Camel Plushie', 'Tribulus Omanense',
|
||||
'Lion Plushie', 'African Violet', 'Xanax',
|
||||
]
|
||||
item_trans_dict = {
|
||||
ITEM_TRANS = {
|
||||
'Dahlia': '花', 'Jaguar Plushie': '偶',
|
||||
'Banana Orchid': '花', 'Stingray Plushie': '偶',
|
||||
'Crocus': '花', 'Wolverine Plushie': '偶',
|
||||
@ -37,126 +33,86 @@ item_trans_dict = {
|
||||
'Cherry Blossom': '花',
|
||||
'Peony': '花', 'Panda Plushie': '偶',
|
||||
'Tribulus Omanense': '花', 'Camel Plushie': '偶',
|
||||
'African Violet': '花', 'Lion Plushie': '偶',
|
||||
'African Violet': '花', 'Lion Plushie': '偶', 'Xanax': 'XAN',
|
||||
}
|
||||
for dest in dest_arr:
|
||||
res_update = resObj["stocks"][dest]["update"]
|
||||
HISTORY_FILE = 'stock_hist.json'
|
||||
HISTORY_EXIST = os.path.exists(HISTORY_FILE)
|
||||
UTC_8 = timezone(timedelta(hours=8))
|
||||
|
||||
URL = "https://yata.yt/api/v1/travel/export/"
|
||||
resObj = requests.get(URL).json()["stocks"]
|
||||
|
||||
# 更新时间
|
||||
lastUpdate = 0
|
||||
for dest in DEST_ARR:
|
||||
res_update = resObj[dest]["update"]
|
||||
if lastUpdate < res_update:
|
||||
lastUpdate = res_update
|
||||
lastUpdate = datetime.fromtimestamp(lastUpdate).astimezone(tzutc_8)
|
||||
seq = ["最后更新 %s\n" % lastUpdate.strftime('%H:%M:%S')]
|
||||
lastUpdate = datetime.fromtimestamp(lastUpdate).astimezone(UTC_8)
|
||||
UPDATE_TIME_STR = lastUpdate.strftime('%H:%M:%S')
|
||||
|
||||
resObj = resObj["stocks"]
|
||||
# 整理过的对象
|
||||
stockObj = {}
|
||||
|
||||
for dest in dest_arr:
|
||||
# if resObj[dest]:
|
||||
# stockObj[dest] = resObj[dest]['stocks']
|
||||
for dest in DEST_ARR:
|
||||
arr = []
|
||||
# for f_item in stockObj[dest]:
|
||||
for f_item in resObj[dest]['stocks']:
|
||||
for v_item in valued_item:
|
||||
for v_item in VALUED_ITEM_ARR:
|
||||
if f_item['name'] == v_item:
|
||||
arr.append(f_item)
|
||||
stockObj[dest] = arr
|
||||
|
||||
# 删除加拿大的xan
|
||||
for item in stockObj['can']:
|
||||
if item['name'] == 'Xanax':
|
||||
del stockObj['can'][item]
|
||||
# 删除英国的xan
|
||||
del stockObj['uni'][3]
|
||||
# 删除日本的xan
|
||||
del stockObj['uni'][3]
|
||||
# 移除亏本的xan
|
||||
# 加拿大
|
||||
index = -1
|
||||
for i in range(len(stockObj['can'])):
|
||||
if stockObj['can'][i]['name'] == 'Xanax':
|
||||
index = i
|
||||
if index != -1:
|
||||
del stockObj['can'][index]
|
||||
# 英国
|
||||
index = -1
|
||||
for i in range(len(stockObj['uni'])):
|
||||
if stockObj['uni'][i]['name'] == 'Xanax':
|
||||
index = i
|
||||
if index != -1:
|
||||
del stockObj['uni'][index]
|
||||
# 日本
|
||||
index = -1
|
||||
for i in range(len(stockObj['jap'])):
|
||||
if stockObj['jap'][i]['name'] == 'Xanax':
|
||||
index = i
|
||||
if index != -1:
|
||||
del stockObj['jap'][index]
|
||||
|
||||
for dest in dest_arr:
|
||||
for f_item in stockObj[dest]:
|
||||
print()
|
||||
# 读取库存历史
|
||||
stockHistObj = {}
|
||||
if HISTORY_EXIST:
|
||||
print('历史文件存在')
|
||||
with open(HISTORY_FILE, 'r') as load_f:
|
||||
stockHistObj = json.load(load_f)
|
||||
else:
|
||||
stockHistObj['json'] = []
|
||||
stockHistObj['json'].append({str(int(datetime.now().timestamp())): stockObj})
|
||||
if len(stockHistObj['json']) > 100:
|
||||
del stockHistObj['json'][0]
|
||||
with open(HISTORY_FILE, 'w') as f:
|
||||
json.dump(stockHistObj, f)
|
||||
hist_arr = stockHistObj['json']
|
||||
|
||||
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"]))
|
||||
|
||||
# 用于写入文件的列表
|
||||
seq = ["更新时间: %s\n" % UPDATE_TIME_STR]
|
||||
for dest in DEST_ARR:
|
||||
seq_str = '%s ' % DEST_TRANS[dest]
|
||||
for i in range(len(stockObj[dest])):
|
||||
seq_str += '%s%s' % (ITEM_TRANS[stockObj[dest][i]['name']], stockObj[dest][i]['quantity'])
|
||||
if i != len(stockObj[dest]) - 1:
|
||||
seq_str += ' '
|
||||
seq_str += '\n'
|
||||
seq.append(seq_str)
|
||||
# 写入文件
|
||||
fo = open(file="stock.txt", mode="w", encoding="utf-8")
|
||||
fo.writelines(seq)
|
||||
fo.close()
|
||||
|
||||
print("花偶库存txt更新完成")
|
||||
print("花偶库存更新完成")
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
// ==UserScript==
|
||||
// @lastmodified 202201130028
|
||||
// @lastmodified 202201142310
|
||||
// @name Torn翻译
|
||||
// @namespace WOOH
|
||||
// @version 0.2.0113a
|
||||
// @version 0.2.0114a
|
||||
// @description Torn UI翻译
|
||||
// @author Woohoo-[2687093] sabrina_devil[2696209]
|
||||
// @match https://www.torn.com/*
|
||||
@ -15,13 +15,18 @@
|
||||
___window___.WHTRANS = true;
|
||||
|
||||
const CC_set = /[\u4e00-\u9fa5]/;
|
||||
const version = '0.2.0113a';
|
||||
const version = '0.2.0114a';
|
||||
|
||||
const changelist = [
|
||||
{
|
||||
todo: true,
|
||||
cont: `翻译:baza npc商店、imarket、imarket搜索结果`,
|
||||
},
|
||||
{
|
||||
ver: '0.2.0114a',
|
||||
date: '20220114',
|
||||
cont: `调整飞行闹钟的样式`,
|
||||
},
|
||||
{
|
||||
ver: '0.2.0113a',
|
||||
date: '20220113',
|
||||
@ -3801,7 +3806,7 @@ padding: 0.5em 0;
|
||||
wh_trv_alarm_node.style.top = `${wh_trv_alarm.node_pos[1] || 240}px`;
|
||||
wh_trv_alarm_node.innerHTML = `<div id="wh-trv-error"><p><b>❌ 权限错误</b><br/>点击网页内任意位置以激活闹钟</p></div>
|
||||
<div id="wh-trv-alarm-title">
|
||||
<div id="wh-trv-alarm-move-btn"><span></span></div>
|
||||
<!-- <div id="wh-trv-alarm-move-btn"><span></span></div>-->
|
||||
<h5 id="wh-trv-alarm-header">飞行闹钟</h5>
|
||||
</div>
|
||||
<div id="wh-trv-alarm-bottom">
|
||||
@ -3809,7 +3814,7 @@ padding: 0.5em 0;
|
||||
<p id="wh-trv-alarm-remaining"></p>
|
||||
<p><span id="wh-trv-status">飞行中...</span><span>✈</span></p>
|
||||
<div><label><input type="checkbox" ${wh_trv_alarm.enable ? 'checked ' : ' '}/> 开启闹钟</label></div>
|
||||
<div><label>落地前响铃时长(单位秒): <input type="number" value="${wh_trv_alarm.alert_time || 30}" /></label><button>确定</button></div>
|
||||
<div><label>落地前响铃时长(秒): <input type="number" value="${wh_trv_alarm.alert_time || 30}" /></label><button>确定</button></div>
|
||||
<div class="wh-trv-alarm-stop-hide"><button>停止闹钟</button></div>
|
||||
</div>
|
||||
</div>
|
||||
@ -3825,6 +3830,7 @@ border-radius:4px;
|
||||
box-shadow:#0000001f 0 0 10px 4px;
|
||||
border:solid 1px #aaa;
|
||||
z-index:100001;
|
||||
margin:2em;
|
||||
}
|
||||
#wh-trv-alarm button{
|
||||
margin:0;
|
||||
@ -3847,14 +3853,15 @@ text-align:center;
|
||||
#wh-trv-alarm-title{
|
||||
height: 30px;
|
||||
border-bottom: solid #aaa 1px;
|
||||
cursor: move;
|
||||
}
|
||||
#wh-trv-alarm-move-btn span{
|
||||
/*#wh-trv-alarm-move-btn span{
|
||||
background:url(/images/v2/home_main/move.svg);
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
float: right;
|
||||
cursor: move;
|
||||
}
|
||||
}*/
|
||||
h5#wh-trv-alarm-header{
|
||||
height: 100%;
|
||||
line-height: 30px;
|
||||
@ -3884,7 +3891,8 @@ display:none;
|
||||
$(wh_trv_alarm_node).draggable({
|
||||
containment: "body",
|
||||
distance: 5,
|
||||
handle: "#wh-trv-alarm-move-btn",
|
||||
handle: "#wh-trv-alarm-title",
|
||||
// handle: "#wh-trv-alarm-move-btn",
|
||||
stop: () => {
|
||||
wh_trv_alarm.node_pos = [parseInt(wh_trv_alarm_node.style.left), parseInt(wh_trv_alarm_node.style.top)];
|
||||
save_trv_settings();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user