From d03a9d146226fddb4cedc20d1ff15bcf557d0887 Mon Sep 17 00:00:00 2001 From: "lzyme.dev@gmail.com" Date: Mon, 31 Aug 2026 11:31:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A3=81=E5=8A=9B=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E9=87=8C=E9=9D=A2=E7=82=B9=E5=87=BB=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E9=87=8D=E5=A4=8D=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/magnet-hub.js | 87 ++++++++++++++++++++------------------- src/plugins/setting.js | 2 +- 2 files changed, 46 insertions(+), 43 deletions(-) diff --git a/src/plugins/magnet-hub.js b/src/plugins/magnet-hub.js index cec3b41..c745c69 100644 --- a/src/plugins/magnet-hub.js +++ b/src/plugins/magnet-hub.js @@ -2,6 +2,30 @@ import { BasePlugin } from '../core/base-plugin.js'; import { __publicField } from '../core/constants.js'; import { GM_xmlhttpRequest } from 'vite-plugin-monkey/dist/client'; +function showCopiedFeedback($btn) { + const originalText = $btn.text(); + $btn.addClass("copied").text("已复制"); + setTimeout((() => { + $btn.removeClass("copied").text(originalText); + }), 2e3); +} + +function fallbackCopy(text, $btn) { + const textarea = document.createElement("textarea"); + textarea.value = text; + textarea.style.position = "fixed"; + document.body.appendChild(textarea); + textarea.select(); + try { + document.execCommand("copy"); + showCopiedFeedback($btn); + } catch (err) { + console.error("复制失败:", err); + alert("复制失败,请手动复制链接"); + } + document.body.removeChild(textarea); +} + class MagnetHubPlugin extends BasePlugin { constructor() { super(...arguments); @@ -63,6 +87,27 @@ class MagnetHubPlugin extends BasePlugin { $(e.target).addClass("active"); this.searchEngine($resultsContainer, this.currentEngine, keyword); })); + $container.on("click", ".copy-btn", function () { + const $btn = $(this), magnet = $btn.data("magnet"); + navigator.clipboard ? navigator.clipboard.writeText(magnet).then((() => { + showCopiedFeedback($btn); + })).catch((() => { + fallbackCopy(magnet, $btn); + })) : fallbackCopy(magnet, $btn); + }); + $container.on("click", ".down-115", (async event => { + event.stopPropagation(); + const magnet = $(event.currentTarget).data("magnet"); + let loadObj = loading(); + try { + await this.getBean("WangPan115TaskPlugin").handleAddTask(magnet); + } catch (e) { + show.error("发生错误:" + e); + console.error(e); + } finally { + loadObj.close(); + } + })); this.searchEngine($resultsContainer, this.currentEngine || this.searchEngines[defaultEngineIndex], keyword); return $container; } @@ -96,49 +141,7 @@ class MagnetHubPlugin extends BasePlugin { const $result = $(`\n
\n \n
\n 大小: ${result.size || "未知"}\n 日期: ${result.date || "未知"}\n
\n
\n \n \n
\n
\n `); $container.append($result); })); - $container.on("click", ".copy-btn", (function() { - const $btn = $(this), magnet = $btn.data("magnet"); - navigator.clipboard ? navigator.clipboard.writeText(magnet).then((() => { - showCopiedFeedback($btn); - })).catch((err => { - fallbackCopy(magnet, $btn); - })) : fallbackCopy(magnet, $btn); - })); - $container.on("click", ".down-115", (async event => { - const magnet = $(event.currentTarget).data("magnet"); - let loadObj = loading(); - try { - await this.getBean("WangPan115TaskPlugin").handleAddTask(magnet); - } catch (e) { - show.error("发生错误:" + e); - console.error(e); - } finally { - loadObj.close(); - } - })); } else $container.append('
没有找到相关结果
'); - function showCopiedFeedback($btn) { - const originalText = $btn.text(); - $btn.addClass("copied").text("已复制"); - setTimeout((() => { - $btn.removeClass("copied").text(originalText); - }), 2e3); - } - function fallbackCopy(text, $btn) { - const textarea = document.createElement("textarea"); - textarea.value = text; - textarea.style.position = "fixed"; - document.body.appendChild(textarea); - textarea.select(); - try { - document.execCommand("copy"); - showCopiedFeedback($btn); - } catch (err) { - console.error("复制失败:", err); - alert("复制失败,请手动复制链接"); - } - document.body.removeChild(textarea); - } } parseBTSOW($container, engine, keyword, cacheKey) { const _this = this; diff --git a/src/plugins/setting.js b/src/plugins/setting.js index e1425b9..64b38cf 100644 --- a/src/plugins/setting.js +++ b/src/plugins/setting.js @@ -139,7 +139,7 @@ class SettingPlugin extends BasePlugin { async simpleSetting() { let settingObj = await storageManager.getSetting(); const showFilterItemHotKey = settingObj.showFilterItemHotKey, showFilterActorItemHotKey = settingObj.showFilterActorItemHotKey, showFilterKeywordItemHotKey = settingObj.showFilterKeywordItemHotKey, showFavoriteItemHotKey = settingObj.showFavoriteItemHotKey, showHasDownItemHotKey = settingObj.showHasDownItemHotKey, showHasWatchItemHotKey = settingObj.showHasWatchItemHotKey, showAllItemHotKey = settingObj.showAllItemHotKey; - return `\n
\n
\n
\n \n 显示已鉴定内容:\n \n
\n 屏蔽单番号${showFilterItemHotKey ? `(${showFilterItemHotKey})` : ""}:
\n 屏蔽演员${showFilterActorItemHotKey ? `(${showFilterActorItemHotKey})` : ""}:
\n 屏蔽关键词${showFilterKeywordItemHotKey ? `(${showFilterKeywordItemHotKey})` : ""}:
\n 收藏${showFavoriteItemHotKey ? `(${showFavoriteItemHotKey})` : ""}:
\n 已下载${showHasDownItemHotKey ? `(${showHasDownItemHotKey})` : ""}:
\n 已观看${showHasWatchItemHotKey ? `(${showHasWatchItemHotKey})` : ""}:
\n
\n
\n
\n \n ❓ 显示所有${showAllItemHotKey ? `(${showAllItemHotKey})` : ""}:\n \n
\n \n
\n
\n \n
\n \n
\n \n ❓ 弹窗方式打开页面:\n \n
\n \n
\n
\n \n
\n 鉴定后立即关闭页面:\n
\n \n
\n
\n \n
\n\n
\n \n ❓ 瀑布流模式:\n \n
\n \n
\n
\n \n
\n 启用标题翻译:\n
\n \n
\n
\n \n
\n 启用悬浮大图:\n
\n \n
\n
\n \n
\n \n ❓ 不规则重命名:(详情页生效,有延迟)\n
\n \n
\n
\n \n \n \n
\n 启用115视频匹配: \n
\n \n
\n
\n \n
\n\n ${isJavDb ? '\n
\n \n ❓ 加载女优信息:\n \n
\n \n
\n
' : ""}\n \n
\n \n ❓ 加载第三方视频资源:\n \n
\n \n
\n
\n \n
\n \n ❓ 加载长缩略图:\n \n
\n \n
\n
\n \n
\n \n ❓ 更高画质预览视频:\n \n
\n \n
\n
\n\n
\n\n
\n \n ❓ 竖图模式:\n \n
\n \n
\n
\n \n
\n 页面列数: \n
\n \n
\n
\n \n
\n 页面宽度: \n
\n \n
\n
\n
\n
\n \n \n
\n
\n `; + return `\n
\n
\n
\n \n 显示已鉴定内容:\n \n
\n 屏蔽单番号${showFilterItemHotKey ? `(${showFilterItemHotKey})` : ""}:
\n 屏蔽演员${showFilterActorItemHotKey ? `(${showFilterActorItemHotKey})` : ""}:
\n 屏蔽关键词${showFilterKeywordItemHotKey ? `(${showFilterKeywordItemHotKey})` : ""}:
\n 收藏${showFavoriteItemHotKey ? `(${showFavoriteItemHotKey})` : ""}:
\n 已下载${showHasDownItemHotKey ? `(${showHasDownItemHotKey})` : ""}:
\n 已观看${showHasWatchItemHotKey ? `(${showHasWatchItemHotKey})` : ""}:
\n
\n
\n
\n \n ❓ 显示所有${showAllItemHotKey ? `(${showAllItemHotKey})` : ""}:\n \n
\n \n
\n
\n \n
\n \n
\n \n ❓ 弹窗方式打开页面:\n \n
\n \n
\n
\n \n
\n 鉴定后立即关闭页面:\n
\n \n
\n
\n \n
\n\n
\n \n ❓ 瀑布流模式:\n \n
\n \n
\n
\n \n
\n 启用标题翻译:\n
\n \n
\n
\n \n
\n 启用悬浮大图:\n
\n \n
\n
\n \n
\n \n ❓ 不规则重命名:(刷新详情页生效,有延迟)\n
\n \n
\n
\n \n \n \n
\n 启用115视频匹配: \n
\n \n
\n
\n \n
\n\n ${isJavDb ? '\n
\n \n ❓ 加载女优信息:\n \n
\n \n
\n
' : ""}\n \n
\n \n ❓ 加载第三方视频资源:\n \n
\n \n
\n
\n \n
\n \n ❓ 加载长缩略图:\n \n
\n \n
\n
\n \n
\n \n ❓ 更高画质预览视频:\n \n
\n \n
\n
\n\n
\n\n
\n \n ❓ 竖图模式:\n \n
\n \n
\n
\n \n
\n 页面列数: \n
\n \n
\n
\n \n
\n 页面宽度: \n
\n \n
\n
\n
\n
\n \n \n
\n
\n `; } async loadForm() { let settingObj = await storageManager.getSetting();