From 820c19dbd1cce125851674ed6b8c518030fe51ca Mon Sep 17 00:00:00 2001 From: fzlins Date: Mon, 31 Jul 2023 09:36:13 -0400 Subject: [PATCH] fix(MDU): Level Requirement --- resource/i18n/en.json | 4 +- resource/i18n/zh-CN.json | 4 +- resource/schemas/UNIT3D/config.json | 5 ++ resource/sites/monikadesign.uk/config.json | 24 ++++++++-- src/interface/common.ts | 6 ++- src/interface/types.expand.js | 39 +++++++++++++++ src/options/views/Home.vue | 56 ++++++++++++++++++++++ 7 files changed, 131 insertions(+), 7 deletions(-) diff --git a/resource/i18n/en.json b/resource/i18n/en.json index 208ecb7ed..4b1dc146b 100644 --- a/resource/i18n/en.json +++ b/resource/i18n/en.json @@ -217,6 +217,7 @@ "bonus": "Bonus", "seedingPoints": "Seeding Points", "seedingTime": "Seeding Time", + "averageSeedtime": "Average Seedtime", "bonusPerHour": "Bonus per hour", "joinTime": "Join time", "lastUpdateTime": "Update at", @@ -230,7 +231,8 @@ "classPoints": "Class Points", "uniqueGroups": "Unique Groups", "perfectFLAC": "\"Perfect\" FLAC", - "alternative": "Alternative" + "alternative": "Alternative", + "days": "Days" }, "tip": "N/A means no support", "nodata": "You have not added a site, please go to [Sites] to add a site." diff --git a/resource/i18n/zh-CN.json b/resource/i18n/zh-CN.json index 38e696f2f..12495905d 100644 --- a/resource/i18n/zh-CN.json +++ b/resource/i18n/zh-CN.json @@ -211,6 +211,7 @@ "seeding": "做种数", "seedingSize": "做种体积", "seedingTime": "做种时间", + "averageSeedtime": "平均做种时间", "bonus": "魔力值", "seedingPoints": "做种积分", "bonusPerHour": "时魔", @@ -225,7 +226,8 @@ "classPoints": "等级积分", "uniqueGroups": "独特分组", "perfectFLAC": "“完美”FLAC", - "alternative": "择一" + "alternative": "择一", + "days": "天" }, "tip": "N/A 表示暂不支持", "nodata": "您还没有添加站点,请前往『站点设置』添加站点。" diff --git a/resource/schemas/UNIT3D/config.json b/resource/schemas/UNIT3D/config.json index 5d20167a2..4d7e7047f 100644 --- a/resource/schemas/UNIT3D/config.json +++ b/resource/schemas/UNIT3D/config.json @@ -120,6 +120,11 @@ "selector": ["a[href$='unsatisfieds']:first"], "attribute": "href", "filters": ["query ? new URL(query).pathname : null"] + }, + "averageSeedtime": { + "selector": ["table.table-condensed.table-striped.table-bordered:first td:contains('Average Seedtime') + td", "table.table-condensed.table-striped.table-bordered:first td:contains('平均做种时间') + td", "table.table-condensed.table-striped.table-bordered:first td:contains('平均做種時間') + td", + "dt:contains('Average Seedtime') + dd", "dt:contains('平均做种时间') + dd", "dt:contains('平均做種時間') + dd"], + "filters": ["query.text().trim().timeToDays()"] } } }, diff --git a/resource/sites/monikadesign.uk/config.json b/resource/sites/monikadesign.uk/config.json index e28c60495..904ebfed0 100644 --- a/resource/sites/monikadesign.uk/config.json +++ b/resource/sites/monikadesign.uk/config.json @@ -22,25 +22,41 @@ "name": "SuperUser", "interval": "8", "uploaded": "2TB", - "privilege": "无" + "privilege": "访问邀请区" },{ "level": "3", "name": "ExtremeUser", "interval": "12", "uploaded": "5TB", - "privilege": "无" + "privilege": "自动通过候选;访问邀请区" },{ "level": "4", "name": "InsaneUser", "interval": "18", "uploaded": "10TB", - "privilege": "自动通过候选" + "privilege": "自动通过候选;访问邀请区" },{ "level": "5", "name": "Veteran", "interval": "36", "uploaded": "15TB", - "privilege": "个人全局双倍上传" + "privilege": "个人全局双倍上传;自动通过候选;访问邀请区" + }, + { + "level": "6", + "name": "Seeder", + "interval": "4", + "seedingSize": "3TB", + "averageSeedtime": "30", + "privilege": "自动通过候选;访问邀请区" + }, + { + "level": "7", + "name": "Archivist", + "interval": "12", + "seedingSize": "10TB", + "averageSeedtime": "60", + "privilege": "个人全局免费;自动通过候选;访问邀请区" }], "collaborator": "fzlins", "searchEntryConfig": { diff --git a/src/interface/common.ts b/src/interface/common.ts index 5313cb706..224362e70 100644 --- a/src/interface/common.ts +++ b/src/interface/common.ts @@ -297,8 +297,10 @@ export interface LevelRequirement { seedingPoints?: number; // 做种时间要求 seedingTime?: number; + // 平均保种时间要求 + averageSeedtime?: number; // 保种体积要求 - seedingSize?: number; + seedingSize?: string | number; // 分享率要求 ratio?: number; // 等级积分要求 @@ -591,6 +593,8 @@ export interface UserInfo { seedingPoints?: number; // 做种时间要求 seedingTime?: number; + // 平均保种时间 + averageSeedtime?: number; // 时魔 bonusPerHour?: number; // 积分页面 diff --git a/src/interface/types.expand.js b/src/interface/types.expand.js index 5511b0183..67bfca55c 100644 --- a/src/interface/types.expand.js +++ b/src/interface/types.expand.js @@ -39,3 +39,42 @@ String.prototype.sizeToNumber = function() { } return 0; }; + +/** + * @return {number} + */ +String.prototype.timeToDays = function() { + const timeMatch = this.match(/\d+[天周月年DWMY]/g); + let length = 0; + if (timeMatch == null) + return 0; + + timeMatch.forEach(time => { + const timeMatch = time.match(/(\d+)([天周月年DWMY])/); + if (timeMatch == null) + return 0; + + const number = parseInt(timeMatch[1]) + const unit = timeMatch[2] + switch (true) { + case unit === 'D': + case unit === '天': + length += number; + break; + case unit === 'W': + case unit === '周': + length += number; + break; + case unit === 'M': + case unit === '月': + length += number * 30; + break; + case unit === 'Y': + case unit === '年': + length += number * 365; + break; + default: + } + }) + return length; +}; diff --git a/src/options/views/Home.vue b/src/options/views/Home.vue index 2b1c248a0..5b76cd55a 100644 --- a/src/options/views/Home.vue +++ b/src/options/views/Home.vue @@ -127,6 +127,11 @@ nextLevel.bonus | formatNumber }}  + + + + + +