javbus open copy

在識別碼行下方新增复制按钮

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         javbus open copy
// @namespace    http://tampermonkey.net/
// @version      0.0.6
// @description  在識別碼行下方新增复制按钮
// @match        https://www.javbus.com/*
// @match        https://www.javbus.bond/*
// @match        https://www.buscdn.bond/*
// @match        https://www.seejav.cyou/*
// @match        https://www.javsee.cyou/*
// @exclude      https://www.javbus.com/forum/*
// @exclude      https://www.javbus.com/forum
// @license      zxuuhh
// @grant        none
// ==/UserScript==

(function () {
  'use strict';

  function showInfo(text, ms = 1200) {
    const div = document.createElement('div');
    div.style.cssText = `
      position:fixed;
      top:10px;
      right:10px;
      padding:8px 12px;
      background:#333;
      color:#fff;
      border-radius:4px;
      z-index:9999;
      font-size:13px;
    `;
    div.textContent = text;
    document.body.appendChild(div);
    setTimeout(() => div.remove(), ms);
  }

  function findCodeP() {
    const ps = document.querySelectorAll('.info p');
    for (const p of ps) {
      const span = p.querySelector('span.header');
      if (span && span.textContent.includes('識別碼')) {
        return p;
      }
    }
    return null;
  }

  function getAvCode() {
    const p = findCodeP();
    if (!p) return '';
    const spans = p.querySelectorAll('span');
    return spans[1]?.innerText.trim() || '';
  }

  async function copyAvCode() {
    const code = getAvCode();
    if (!code) {
      showInfo('未获取到番号');
      return;
    }
    await navigator.clipboard.writeText(code);
    showInfo(`已复制 ${code}`);
  }

  function insertButton() {
    const p = findCodeP();
    if (!p || p.dataset.btnAdded) return;

    p.dataset.btnAdded = '1';

    const btn = document.createElement('button');
    btn.textContent = '复制番号';
    btn.style.cssText = `
      margin-top:6px;
      padding:4px 10px;
      font-size:12px;
      cursor:pointer;
    `;

    btn.addEventListener('click', copyAvCode);

    // 插入到「識別碼」这一行下面
    p.insertAdjacentElement('afterend', btn);
  }

  const timer = setInterval(insertButton, 500);
})();