From c1dd784e9b8fa54aaa0c5396acd642d8ea46a508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Thu, 5 Sep 2024 15:52:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E8=B0=83=E6=95=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tampermonkey.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tampermonkey.js b/tampermonkey.js index 881c2ec..b4cbba0 100644 --- a/tampermonkey.js +++ b/tampermonkey.js @@ -636,15 +636,15 @@ // 设置info if (typeof info === "function") { callback = info; - info = null; + info = {}; } else if (typeof info === "string") { info = { type: info }; } else if (typeof info !== "object") { - info = null; + info = {}; } try { - if (info != null && typeof info.mimetype === "string") { + if (typeof info.mimetype === "string") { const blob = new Blob([data], { type: info.mimetype }); const data = [new ClipboardItem({ [info.mimetype]: blob })]; await navigator.clipboard.write(data); @@ -665,10 +665,12 @@ } // 提示设置成功 - api.GM_notification({ - text: '内容复制成功,请使用 Ctrl+V 粘贴内容吧!', - timeout: 3500 - }); + if (info.notification !== false) { + api.GM_notification({ + text: '内容复制成功,请使用 Ctrl+V 粘贴内容吧!', + timeout: 3500 + }); + } } catch (e) { console.error(`ds_tampermonkey_${version}: GM_setClipboard: 写入剪贴板失败:`, e); return;