javbus open copy

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

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

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