javbus open copy

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

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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);
})();