Skip to content

Commit b0cb2b9

Browse files
committed
✨ 根据浏览器内核版本显示对应的提示
1 parent c03ebaf commit b0cb2b9

7 files changed

Lines changed: 45 additions & 11 deletions

File tree

src/locales/ach-UG/translation.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"last_24_hours": "crwdns5984:0crwdne5984:0",
9494
"last_7_days": "crwdns5986:0crwdne5986:0",
9595
"query": "crwdns5988:0crwdne5988:0",
96-
"labels": "crwdns5990:0crwdne5990:0",
96+
"labels": "crwdns7008:0crwdne7008:0",
9797
"search_regex": "crwdns5992:0crwdne5992:0",
9898
"clean_schedule": "crwdns5994:0crwdne5994:0",
9999
"days_ago_logs": "crwdns5996:0crwdne5996:0",
@@ -107,7 +107,7 @@
107107
"permission": "crwdns6012:0crwdne6012:0",
108108
"enter_subscribe_name": "crwdns6014:0crwdne6014:0",
109109
"subscribe_url": "crwdns6016:0crwdne6016:0",
110-
"confirm_delete_subscription": "crwdns6018:0crwdne6018:0",
110+
"confirm_delete_subscription": "crwdns7010:0crwdne7010:0",
111111
"list": {
112112
"confirm_delete": "crwdns6020:0crwdne6020:0",
113113
"confirm_update": "crwdns6022:0crwdne6022:0"
@@ -137,6 +137,7 @@
137137
"script_link": "crwdns6068:0crwdne6068:0",
138138
"user_installation": "crwdns6070:0crwdne6070:0",
139139
"confirm_delete_script": "crwdns6072:0crwdne6072:0",
140+
"confirm_delete_script_content": "crwdns7012:0{{name}}crwdne7012:0",
140141
"delete_failed": "crwdns6074:0crwdne6074:0",
141142
"enter_script_name": "crwdns6076:0crwdne6076:0",
142143
"update_not_supported": "crwdns6078:0crwdne6078:0",
@@ -316,7 +317,7 @@
316317
"current_page_scripts": "crwdns6418:0crwdne6418:0",
317318
"enabled_background_scripts": "crwdns6420:0crwdne6420:0",
318319
"script_accessing_cross_origin_resource": "crwdns6422:0crwdne6422:0",
319-
"confirm_operation_description": "crwdns6512:0crwdne6512:0",
320+
"confirm_operation_description": "crwdns7014:0crwdne7014:0",
320321
"domain": "crwdns6426:0crwdne6426:0",
321322
"script_name": "crwdns6428:0crwdne6428:0",
322323
"request_domain": "crwdns6430:0crwdne6430:0",
@@ -370,6 +371,7 @@
370371
"get_backup_dir_url_failed": "crwdns6932:0crwdne6932:0",
371372
"get_backup_files_failed": "crwdns6934:0crwdne6934:0",
372373
"develop_mode_guide": "crwdns6936:0crwdne6936:0",
374+
"allow_user_script_guide": "crwdns7018:0crwdne7018:0",
373375
"enable_script_failed": "crwdns6938:0crwdne6938:0",
374376
"disable_script_failed": "crwdns6940:0crwdne6940:0",
375377
"confirm_leave_page": "crwdns6944:0crwdne6944:0",

src/locales/en/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
"script_link": "Script Link",
138138
"user_installation": "Installation",
139139
"confirm_delete_script": "Are you sure you want to delete this script?",
140+
"confirm_delete_script_content": "Are you sure you want to delete the script \"{{name}}\"? This action cannot be undone.",
140141
"delete_failed": "Deletion Failed",
141142
"enter_script_name": "Please enter script name",
142143
"update_not_supported": "This script does not support update checks",
@@ -370,6 +371,7 @@
370371
"get_backup_dir_url_failed": "Failed to get backup directory address",
371372
"get_backup_files_failed": "Failed to fetch backups",
372373
"develop_mode_guide": "Developer mode has not been detected. Your script is not working, <a href=\"https://docs.scriptcat.org/docs/use/open-dev/\" target=\"black\" style=\"color: var(--color-text-1)\">👉tap to learn how to enable</a>.",
374+
"allow_user_script_guide": "Allow User Scripts has not been detected. Your script is not working, <a href=\"https://docs.scriptcat.org/docs/use/open-dev/\" target=\"black\" style=\"color: var(--color-text-1)\">👉tap to learn how to enable</a>",
373375
"enable_script_failed": "Failed to Enable Script",
374376
"disable_script_failed": "Failed to Close Script",
375377
"confirm_leave_page": "Currently editing status. Leaving this page will lose the current content. Do you want to leave?",
@@ -404,4 +406,4 @@
404406
"build_failed": "Failed to Build",
405407
"drag_script_here_to_upload": "Drag script here to upload it",
406408
"sync_status": "Sync Status"
407-
}
409+
}

src/locales/vi/translation.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"last_24_hours": "24 Giờ Gần Nhất",
9494
"last_7_days": "7 Ngày Gần Nhất",
9595
"query": "Truy Vấn",
96-
"labels": "Nhãn",
96+
"labels": "Labels",
9797
"search_regex": "Tìm Kiếm (Hỗ Trợ Regex)",
9898
"clean_schedule": "Dọn Dẹp Lịch Trình",
9999
"days_ago_logs": "Logs Của {{days}} Ngày Trước",
@@ -107,7 +107,7 @@
107107
"permission": "Quyền",
108108
"enter_subscribe_name": "Vui Lòng Nhập Tên Đăng Ký",
109109
"subscribe_url": "Url Đăng Ký",
110-
"confirm_delete_subscription": "Bạn Có Chắc Chắn Muốn Xóa Đăng Ký Này Không? Các Script Liên Quan Cũng Sẽ Bị Xóa",
110+
"confirm_delete_subscription": "确定要删除此订阅吗?相关的脚本也会被删除",
111111
"list": {
112112
"confirm_delete": "Bạn Có Chắc Chắn Muốn Xóa Không? Xin Lưu Ý Rằng Điều Này Và Dán Vào Phần Văn Bản Còn Lại.",
113113
"confirm_update": "Bạn Có Chắc Chắn Muốn Cập Nhật Không? Xin Lưu Ý Rằng Đây Là Một Thao Tác Không Thể Hoàn Tác."
@@ -137,6 +137,7 @@
137137
"script_link": "Liên Kết Script",
138138
"user_installation": "Cài Đặt",
139139
"confirm_delete_script": "Bạn Có Chắc Chắn Muốn Xóa Script Này Không?",
140+
"confirm_delete_script_content": "确定要删除脚本\"{{name}}\"吗?此操作无法撤销。",
140141
"delete_failed": "Xóa Thất Bại",
141142
"enter_script_name": "Vui Lòng Nhập Tên Script",
142143
"update_not_supported": "Script Này Không Hỗ Trợ Kiểm Tra Cập Nhật",
@@ -316,7 +317,7 @@
316317
"current_page_scripts": "Script Đang Chạy Trên Trang Hiện Tại",
317318
"enabled_background_scripts": "Script Nền Đã Bật Và Đang Chạy",
318319
"script_accessing_cross_origin_resource": "Script Đang Thử Truy Cập Tài Nguyên Từ Nguồn Gốc Khác",
319-
"confirm_operation_description": "Vui Lòng Xác Nhận Nếu Bạn Cho Phép Script Thực Hiện Thao Tác Này. Script Cũng Có Thể Thêm Thẻ @connect Để Bỏ Qua Tùy Chọn Này.",
320+
"confirm_operation_description": "请您确认是否允许脚本进行此操作,脚本也可增加@connect标签跳过此选项",
320321
"domain": "Tên Miền",
321322
"script_name": "Tên Script",
322323
"request_domain": "Tên Miền Yêu Cầu",
@@ -370,6 +371,7 @@
370371
"get_backup_dir_url_failed": "获取备份目录地址失败",
371372
"get_backup_files_failed": "获取备份文件失败",
372373
"develop_mode_guide": "检测到当前未开启开发者模式,您的脚本无法正常使用,<a href=\"https://docs.scriptcat.org/docs/use/open-dev/\" target=\"black\" style=\"color: var(--color-text-1)\">👉点我了解如何开启</a>",
374+
"allow_user_script_guide": "检测到当前未开启允许用户脚本,您的脚本无法正常使用,<a href=\"https://docs.scriptcat.org/docs/use/open-dev/\" target=\"black\" style=\"color: var(--color-text-1)\">👉点我了解如何开启</a>",
373375
"enable_script_failed": "脚本开启失败",
374376
"disable_script_failed": "脚本关闭失败",
375377
"confirm_leave_page": "当前正在编辑状态,跳转其它页面将会丢失当前内容,是否跳转?",

src/locales/zh-CN/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@
371371
"get_backup_dir_url_failed": "获取备份目录地址失败",
372372
"get_backup_files_failed": "获取备份文件失败",
373373
"develop_mode_guide": "检测到当前未开启开发者模式,您的脚本无法正常使用,<a href=\"https://docs.scriptcat.org/docs/use/open-dev/\" target=\"black\" style=\"color: var(--color-text-1)\">👉点我了解如何开启</a>",
374+
"allow_user_script_guide": "检测到当前未开启允许用户脚本,您的脚本无法正常使用,<a href=\"https://docs.scriptcat.org/docs/use/open-dev/\" target=\"black\" style=\"color: var(--color-text-1)\">👉点我了解如何开启</a>",
374375
"enable_script_failed": "脚本开启失败",
375376
"disable_script_failed": "脚本关闭失败",
376377
"confirm_leave_page": "当前正在编辑状态,跳转其它页面将会丢失当前内容,是否跳转?",

src/locales/zh-TW/translation.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
"update_not_supported": "此腳本不支援檢查更新",
144144
"checking_for_updates": "正在檢查更新...",
145145
"new_version_available": "有新版本",
146-
"latest_version": "已是最新版本",
146+
"latest_version": "已經是最新版本",
147147
"checked_for_all_selected": "所選腳本皆已檢查更新",
148148
"update_check_failed": "檢查更新失敗",
149149
"stopping_script": "正在停止腳本",
@@ -187,7 +187,7 @@
187187
"script_resource": "腳本資源",
188188
"permission_value": "授權值",
189189
"allow": "是否允許",
190-
"": "",
190+
"yes": "",
191191
"no": "",
192192
"confirm_delete_permission": "確定要刪除此授權嗎?",
193193
"script_setting": "腳本設定",
@@ -371,6 +371,7 @@
371371
"get_backup_dir_url_failed": "取得備份目錄網址失敗",
372372
"get_backup_files_failed": "取得備份檔案失敗",
373373
"develop_mode_guide": "偵測到目前未開啟開發者模式,您的腳本無法正常使用,<a href=\"https://docs.scriptcat.org/docs/use/open-dev/\" target=\"_blank\" style=\"color: var(--color-text-1)\">👉點我了解如何開啟</a>",
374+
"allow_user_script_guide": "偵測到目前未開啟允許使用者腳本,您的腳本無法正常使用,<a href=\"https://docs.scriptcat.org/docs/use/open-dev/\" target=\"_blank\" style=\"color: var(--color-text-1)\">👉點我了解如何開啟</a>",
374375
"enable_script_failed": "腳本開啟失敗",
375376
"disable_script_failed": "腳本停用失敗",
376377
"confirm_leave_page": "目前正在編輯狀態,跳轉其他頁面將會遺失目前內容,是否跳轉?",

src/pages/popup/App.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import ScriptMenuList from "../components/ScriptMenuList";
1919
import { popupClient, scriptClient } from "../store/features/script";
2020
import { ScriptMenu } from "@App/app/service/service_worker/popup";
2121
import { systemConfig } from "../store/global";
22-
import { isUserScriptsAvailable } from "@App/pkg/utils/utils";
22+
import { getBrowserVersion, isEdge, isUserScriptsAvailable } from "@App/pkg/utils/utils";
2323

2424
const CollapseItem = Collapse.Item;
2525

@@ -90,7 +90,18 @@ function App() {
9090
return (
9191
<>
9292
{!isUserScriptsAvailable() && (
93-
<Alert type="warning" content={<div dangerouslySetInnerHTML={{ __html: t("develop_mode_guide") }} />} />
93+
<Alert
94+
type="warning"
95+
content={
96+
<div
97+
dangerouslySetInnerHTML={{
98+
__html:
99+
// Edge浏览器目前没有允许用户脚本选项,开启开发者模式即可
100+
getBrowserVersion() >= 138 && !isEdge() ? t("allow_user_script_guide") : t("develop_mode_guide"),
101+
}}
102+
/>
103+
}
104+
/>
94105
)}
95106
{isBlacklist && <Alert type="warning" content={t("page_in_blacklist")} />}
96107
<Card

src/pkg/utils/utils.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,3 +275,18 @@ export function isUserScriptsAvailable() {
275275
return false;
276276
}
277277
}
278+
279+
// 获取浏览器内核版本
280+
export function getBrowserVersion(): number {
281+
try {
282+
return Number(navigator.userAgent.match(/(Chrome|Chromium)\/([0-9]+)/)?.[2]);
283+
} catch (e) {
284+
console.error("Error getting browser version:", e);
285+
return 0; // 返回0表示获取失败
286+
}
287+
}
288+
289+
// 判断是否为Edge浏览器
290+
export function isEdge(): boolean {
291+
return navigator.userAgent.indexOf("Edg/") !== -1;
292+
}

0 commit comments

Comments
 (0)