filecxx_activation_code

文件蜈蚣自动获取时间然后拷贝到剪切板

// ==UserScript==
// @name       filecxx_activation_code
// @namespace  npm/vite-plugin-monkey
// @version    0.0.0
// @license MIT
// @icon       https://vitejs.dev/logo.svg
// @match      https://filecxx.com/en_US/activation_code.html
// @require    https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.global.prod.js
// @grant      GM_addStyle
// @description 文件蜈蚣自动获取时间然后拷贝到剪切板
// ==/UserScript==

(function (vue) {
  'use strict';

  const d=new Set;const importCSS = async e=>{d.has(e)||(d.add(e),(t=>{typeof GM_addStyle=="function"?GM_addStyle(t):document.head.appendChild(document.createElement("style")).append(t);})(e));};

  const styleCss = ":root{font-family:Inter,Avenir,Helvetica,Arial,sans-serif;font-size:16px;line-height:24px;font-weight:400;color-scheme:light dark;color:#ffffffde;background-color:#242424;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-text-size-adjust:100%}a{font-weight:500;color:#646cff;text-decoration:inherit}a:hover{color:#535bf2}body{margin:0;display:flex;place-items:center;min-width:320px;min-height:100vh}h1{font-size:3.2em;line-height:1.1}button{border-radius:8px;border:1px solid transparent;padding:.6em 1.2em;font-size:1em;font-weight:500;font-family:inherit;background-color:#1a1a1a;cursor:pointer;transition:border-color .25s}button:hover{border-color:#646cff}button:focus,button:focus-visible{outline:4px auto -webkit-focus-ring-color}.card{padding:2em}#app{max-width:1280px;margin:0 auto;padding:2rem;text-align:center}@media (prefers-color-scheme: light){:root{color:#213547;background-color:#fff}a:hover{color:#747bff}button{background-color:#f9f9f9}}";
  importCSS(styleCss);
  const _sfc_main = vue.defineComponent({
    __name: "App",
    setup(__props) {
      function getCurrentActivationCode() {
        const now = new Date();
        const codesElement = document.getElementById("codes");
        if (!codesElement) {
          return {
            code: "错误:找不到 ID 为 'codes' 的元素。",
            timeRange: null,
            currentTime: now.toLocaleString()
          };
        }
        const rawText = codesElement.textContent?.trim() || "";
        const codeBlocks = rawText.split(/\n{2,}/g).filter((block) => block.trim().length > 0);
        let activeCode = "未找到有效的激活码。当前时间不匹配任何时间段。";
        let matchedRange = null;
        for (const block of codeBlocks) {
          const lines = block.trim().split("\n");
          if (lines.length >= 2) {
            const timeRangeStr = lines[0].trim();
            const code = lines[1].trim();
            const times = timeRangeStr.split(" - ");
            if (times.length === 2) {
              const startTime = new Date(times[0]);
              const endTime = new Date(times[1]);
              if (now >= startTime && now < endTime) {
                activeCode = code;
                matchedRange = timeRangeStr;
                return {
                  code: activeCode,
                  timeRange: matchedRange,
                  currentTime: now.toLocaleString()
                };
              }
            }
          }
        }
        return {
          code: activeCode,
          timeRange: matchedRange,
          currentTime: now.toLocaleString()
        };
      }
      function copyToClipboard(textToCopy) {
        if (navigator.clipboard && window.isSecureContext) {
          navigator.clipboard.writeText(textToCopy).then(() => {
            console.log("成功复制到剪贴板:", textToCopy);
          }).catch((err) => {
            console.error("无法复制到剪贴板:", err);
          });
        } else {
          console.log("不安全的方法");
        }
      }
      const main = () => {
        console.log("APP.vue被加载");
        const result = getCurrentActivationCode();
        console.log("--- TS 查找结果 ---");
        console.log(`当前时间 (本地): ${result.currentTime}`);
        console.log(`匹配的时间段: ${result.timeRange || "N/A"}`);
        console.log(`${result.code}`);
        copyToClipboard(result.code);
      };
      setTimeout(main, 3e3);
      return (_ctx, _cache) => {
        return null;
      };
    }
  });
  vue.createApp(_sfc_main).mount(
    (() => {
      const app = document.createElement("div");
      document.body.append(app);
      return app;
    })()
  );

})(Vue);