javbus open copy

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

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