javbus open copy

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

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

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