小调整。

scripts
王良 2024-09-05 15:52:46 +08:00
parent 6b9322cea9
commit c1dd784e9b
1 changed files with 9 additions and 7 deletions

View File

@ -636,15 +636,15 @@
// 设置info // 设置info
if (typeof info === "function") { if (typeof info === "function") {
callback = info; callback = info;
info = null; info = {};
} else if (typeof info === "string") { } else if (typeof info === "string") {
info = { type: info }; info = { type: info };
} else if (typeof info !== "object") { } else if (typeof info !== "object") {
info = null; info = {};
} }
try { try {
if (info != null && typeof info.mimetype === "string") { if (typeof info.mimetype === "string") {
const blob = new Blob([data], { type: info.mimetype }); const blob = new Blob([data], { type: info.mimetype });
const data = [new ClipboardItem({ [info.mimetype]: blob })]; const data = [new ClipboardItem({ [info.mimetype]: blob })];
await navigator.clipboard.write(data); await navigator.clipboard.write(data);
@ -665,10 +665,12 @@
} }
// 提示设置成功 // 提示设置成功
api.GM_notification({ if (info.notification !== false) {
text: '内容复制成功,请使用 Ctrl+V 粘贴内容吧!', api.GM_notification({
timeout: 3500 text: '内容复制成功,请使用 Ctrl+V 粘贴内容吧!',
}); timeout: 3500
});
}
} catch (e) { } catch (e) {
console.error(`ds_tampermonkey_${version}: GM_setClipboard: 写入剪贴板失败:`, e); console.error(`ds_tampermonkey_${version}: GM_setClipboard: 写入剪贴板失败:`, e);
return; return;