diff --git a/bw/index.html b/bw/index.html index 0690d35..fc00005 100644 --- a/bw/index.html +++ b/bw/index.html @@ -17,7 +17,7 @@ let scriptCont; let replace; - fetch('conf.json') + fetch(`conf.json?${performance.now()}`) .then(response => response.json()) .then(data => { latest = data['latest']; @@ -31,7 +31,7 @@ if (!latest) return; load.disabled = true; status.innerHTML = '正在加载脚本文件'; - fetch(latest[0].name) + fetch(`${latest[0].name}?${performance.now()}`) .then(response => response.text()) .then(text => { status.innerHTML = '脚本加载完成'; diff --git a/fstock.py b/fstock.py index 9107efe..f0a2920 100644 --- a/fstock.py +++ b/fstock.py @@ -1,5 +1,5 @@ -from datetime import datetime,timezone,timedelta - +from datetime import datetime, timezone, timedelta +from copy import deepcopy import requests url = "https://yata.yt/api/v1/travel/export/" @@ -8,6 +8,37 @@ 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 = { + 'mex': '墨', 'cay': '开', 'can': '加', + 'haw': '夏', 'uni': '嘤', 'arg': '阿', + 'swi': '瑞', 'jap': '日', 'chi': '中', 'uae': '迪', 'sou': '南', +} +valued_item = [ + 'Dahlia', 'Jaguar Plushie', + 'Banana Orchid', 'Stingray Plushie', + 'Crocus', 'Wolverine Plushie', + 'Orchid', 'Large Suitcase', + 'Red Fox Plushie', 'Nessie Plushie', 'Heather', + 'Ceibo Flower', 'Monkey Plushie', 'Tear Gas', + 'Chamois Plushie', 'Edelweiss', + 'Cherry Blossom', + 'Panda Plushie', 'Peony', + 'Camel Plushie', 'Tribulus Omanense', + 'Lion Plushie', 'African Violet', 'Xanax', +] +item_trans_dict = { + 'Dahlia': '花', 'Jaguar Plushie': '偶', + 'Banana Orchid': '花', 'Stingray Plushie': '偶', + 'Crocus': '花', 'Wolverine Plushie': '偶', + 'Orchid': '花', 'Large Suitcase': '大箱', + 'Red Fox Plushie': '赤狐', 'Nessie Plushie': '水怪', 'Heather': '花', + 'Ceibo Flower': '花', 'Monkey Plushie': '偶', 'Tear Gas': '催泪弹', + 'Edelweiss': '花', 'Chamois Plushie': '偶', + 'Cherry Blossom': '花', + 'Peony': '花', 'Panda Plushie': '偶', + 'Tribulus Omanense': '花', 'Camel Plushie': '偶', + 'African Violet': '花', 'Lion Plushie': '偶', +} for dest in dest_arr: res_update = resObj["stocks"][dest]["update"] if lastUpdate < res_update: @@ -15,6 +46,33 @@ for dest in dest_arr: lastUpdate = datetime.fromtimestamp(lastUpdate).astimezone(tzutc_8) seq = ["最后更新 %s\n" % lastUpdate.strftime('%H:%M:%S')] +resObj = resObj["stocks"] +stockObj = {} + +for dest in dest_arr: + # if resObj[dest]: + # stockObj[dest] = resObj[dest]['stocks'] + arr = [] + # for f_item in stockObj[dest]: + for f_item in resObj[dest]['stocks']: + for v_item in valued_item: + 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] + +for dest in dest_arr: + for f_item in stockObj[dest]: + print() + mexStock = {} for stock in resObj["stocks"]["mex"]["stocks"]: if "Dahlia" == stock["name"]: diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js index 0613d86..f64e402 100644 --- a/torn-trans-zhcn.user.js +++ b/torn-trans-zhcn.user.js @@ -1,8 +1,8 @@ // ==UserScript== -// @lastmodified 202201111440 +// @lastmodified 202201130028 // @name Torn翻译 // @namespace WOOH -// @version 0.2.0111a +// @version 0.2.0113a // @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.0111a'; + const version = '0.2.0113a'; const changelist = [ { todo: true, cont: `翻译:baza npc商店、imarket、imarket搜索结果`, }, + { + ver: '0.2.0113a', + date: '20220113', + cont: `添加飞行闹钟`, + }, { ver: '0.2.0111a', date: '20220111', @@ -2960,6 +2965,8 @@ {key: 'xmasTownNotify', val: true}, // 起飞爆e {key: 'energyAlert', val: true}, + // 飞行闹钟 + {key: 'trvAlarm', val: true}, // 光速拔刀 6-关闭 {key: 'quickAttIndex', val: 2}, // 光速跑路 0-leave 1-mug 2-hos 3-关闭 @@ -2992,6 +2999,8 @@ xmasTownNotify: undefined, // 起飞爆e energyAlert: undefined, + // 飞行闹钟 + trvAlarm: undefined, // 光速拔刀 6-关闭 quickAttIndex: undefined, // 光速跑路 0-leave 1-mug 2-hos 3-关闭 @@ -3098,6 +3107,13 @@ domText: ' 起飞爆E警告', dictName: 'energyAlert', }) + // 飞行闹钟 + settingsArr.push({ + domType: 'checkbox', + domId: 'wh-trv-alarm-check', + domText: ' 飞行闹钟(仅PC)', + dictName: 'energyAlert', + }) // 攻击链接转跳 settingsArr.push({ domType: 'checkbox', @@ -3261,11 +3277,11 @@ settingsArr.push({ domType: 'button', domId: 'wh-danger-zone', - domText: '危险行为', + domText: '危险功能', clickFunc: function (e) { e.target.blur(); - const insert = `
即将打开危险功能,这些功能可能会造成账号封禁。请自行考虑是否使用。
- + const insert = `即将打开危险功能,使用这些功能可能会造成账号封禁。请自行考虑是否使用。
+ `; popupMsg(insert, '⚠️警告'); // const close_btn = document.querySelector('#wh-popup-close'); @@ -3343,7 +3359,7 @@ padding:16px !important; #wh-trans-icon.wh-icon-expanded .wh-container{display:block;} #wh-latest-version{ display:inline-block; -background-image:url("https://jjins.github.io/t2i/version.png"); +background-image:url("https://jjins.github.io/t2i/version.png?${performance.now()}"); height:16px; width: 66px;} #wh-popup{ @@ -3736,39 +3752,249 @@ padding: 0.5em 0; * 飞行页面 */ if (window.location.href.indexOf('index.php') >= 0 && - $('div.travelling h4').length !== 0 && - wh_trans_settings.transEnable) { - const travelOB = new MutationObserver(travelOBInit); + !!document.querySelector('div.travelling h4')) { + if (wh_trans_settings.transEnable) { + const travelOB = new MutationObserver(travelOBInit); + + function travelOBInit() { + travelOB.disconnect(); + travelTrans(); + travelOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true}); + } + + function travelTrans() { + titleTrans(); + contentTitleLinksTrans(); + + // 气泡 + if (tipsDict[$('div.inner-popup').text().trim()]) + $('div.inner-popup').text(tipsDict[$('div.inner-popup').text().trim()]); + // Remaining Flight Time - + $('div.destination-title span').contents().each((i, e) => { + if (e.childNodes.length !== 0) return; + if (!e.nodeValue) return; + if (travelingDict[e.nodeValue.trim()]) + e.nodeValue = travelingDict[e.nodeValue.trim()]; + }); + // torntools扩展插件落地时间 + if ($('div.tt-landing-time span.description').text().split(' ')[0] === 'Landing') { + const landingTime = $('div.tt-landing-time span.description').text().slice(11, 19); + $('div.tt-landing-time span.description').text('于 ' + landingTime + ' 降落'); + } + } - function travelOBInit() { - travelOB.disconnect(); travelTrans(); travelOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true}); } + // 飞行闹钟 + if (device === 'pc' && wh_trans_settings.energyAlert) elementReady('#countrTravel.hasCountdown').then(node => { + const remaining_arr = node.innerText.trim().split(':'); - function travelTrans() { - titleTrans(); - contentTitleLinksTrans(); + const wh_trv_alarm = localStorage.getItem('wh_trv_alarm') + ? JSON.parse(localStorage.getItem('wh_trv_alarm')) + : {'enable': true, 'alert_time': 30, 'node_pos': [240, 240]}; + const save_trv_settings = () => localStorage.setItem('wh_trv_alarm', JSON.stringify(wh_trv_alarm)); - // 气泡 - if (tipsDict[$('div.inner-popup').text().trim()]) - $('div.inner-popup').text(tipsDict[$('div.inner-popup').text().trim()]); - // Remaining Flight Time - - $('div.destination-title span').contents().each((i, e) => { - if (e.childNodes.length !== 0) return; - if (!e.nodeValue) return; - if (travelingDict[e.nodeValue.trim()]) - e.nodeValue = travelingDict[e.nodeValue.trim()]; + const wh_trv_alarm_node = document.createElement('div'); + wh_trv_alarm_node.id = 'wh-trv-alarm'; + wh_trv_alarm_node.style.left = `${wh_trv_alarm.node_pos[0] || 240}px`; + wh_trv_alarm_node.style.top = `${wh_trv_alarm.node_pos[1] || 240}px`; + wh_trv_alarm_node.innerHTML = `❌ 权限错误
点击网页内任意位置以激活闹钟
飞行中...✈
+ + + +