旅法师营地套牌广场复制卡组代码

按 ctrl+c 直接复制卡组代码

As of 2024-10-07. See the latest version.

// ==UserScript==
// @name         旅法师营地套牌广场复制卡组代码
// @namespace    http://tampermonkey.net/
// @version      0.0.2
// @description  按 ctrl+c 直接复制卡组代码
// @author       mission522
// @match        https://www.iyingdi.com/web/tools/hearthstone/userdecks/deckdetail/*
// @icon         https://pic.iyingdi.com/yingdi_pc/logo.png
// @license      MIT
// @grant        none
// ==/UserScript==

document.addEventListener("keydown", async function (event) {
  if (event.ctrlKey && event.key !== "c") {
    return;
  }

  try {
    const codeNode = document.querySelector(".deck-info-box .staticCode");
    const codeValue = codeNode.textContent.split(":")[1];
    if (!codeValue) throw new Error("未找到卡组代码");

    await navigator.clipboard.writeText(codeValue);

    web.utility.showBasicPrompt({
      content: "代码复制成功",
      style: "alert-success",
    });
  } catch (error) {
    console.error("复制卡组代码时出错:", error);
    web.utility.showBasicPrompt({
      content: `复制卡组代码失败`,
      style: "alert-error",
    });
  }
});