☰

GEVI - Enhancer

Automatically selects entries in dropdowns and buttons on /movies* and /performer* pages, also adds search link to pbc.xxx/*. Some other tweaks too.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

このスクリプトの質問や評価の投稿はこちら、通報はこちらへお寄せください
// ==UserScript==
// @name         GEVI - Enhancer
// @namespace    https://github.com/BD9Max/userscripts
// @version      1.3
// @description  Automatically selects entries in dropdowns and buttons on /movies* and /performer* pages, also adds search link to pbc.xxx/*. Some other tweaks too.
// @author       krbd9max
// @license      MIT
// @match        https://gayeroticvideoindex.com/*
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function () {
  'use strict';

  // Auto-select 100 entries
  function setLengthTo100() {
    const selects = document.querySelectorAll(
      'select[name$="_length"], .dataTables_length select, select'
    );

    selects.forEach(sel => {
      const opt100 = Array.from(sel.options).find(
        o => o.value === '100' || o.textContent.trim() === '100'
      );
      if (opt100 && sel.value !== '100') {
        sel.value = '100';
        sel.dispatchEvent(new Event('change', { bubbles: true }));
      }
    });
  }

  // 2. Auto-select "Hide Compilations"
  function selectHideCompilations() {
    const candidates = [
      ...document.querySelectorAll('input[type="radio"], input[type="checkbox"]')
    ];

    for (const input of candidates) {
      const value = (input.value || '').toLowerCase();
      const id = (input.id || '').toLowerCase();
      const name = (input.name || '').toLowerCase();
      const label = input.labels?.[0]?.textContent?.toLowerCase() || '';
      const parentText = input.parentElement?.textContent?.toLowerCase() || '';

      if (
        value.includes('hide') ||
        id.includes('hide') ||
        name.includes('hide') ||
        label.includes('hide compilations') ||
        parentText.includes('hide compilations')
      ) {
        if (!input.checked) {
          input.checked = true;
          input.dispatchEvent(new Event('change', { bubbles: true }));
          input.dispatchEvent(new Event('click', { bubbles: true }));
        }
        return;
      }
    }

    // Fallback: click element containing the text
    const textNodes = document.evaluate(
      "//*[contains(translate(text(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'hide compilations')]",
      document,
      null,
      XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
      null
    );

    for (let i = 0; i < textNodes.snapshotLength; i++) {
      const el = textNodes.snapshotItem(i);
      const clickable = el.closest('label, button, a, span, div') || el;
      clickable.click();
      break;
    }
  }

  // Add pbc.xxx search link next to performer name
  function addPerformerSearchLink() {
    if (!location.pathname.startsWith('/performer/')) return;

    // Target the h1 that contains the performer name
    const h1 = document.querySelector('h1.text-3xl.text-yellow-200, h1.text-yellow-200, .pt-2 > h1');
    if (!h1 || h1.dataset.pbcLinkAdded) return;

    const name = h1.textContent.trim();
    if (!name) return;

    const searchUrl = 'https://pbc.xxx/w/index.php?search=' + encodeURIComponent(name).replace(/%20/g, '+');

    const link = document.createElement('a');
    link.href = searchUrl;
    link.target = '_self';
    link.rel = 'noopener noreferrer';
    link.textContent = ' [PBC]';
    link.title = 'Search on pbc.xxx';
    link.style.cssText = 'margin-left: 0.5rem; font-size: 0.7em; color: #60a5fa; text-decoration: none; vertical-align: middle;';
    link.onmouseover = () => link.style.textDecoration = 'underline';
    link.onmouseout  = () => link.style.textDecoration = 'none';

    // Insert right after the name (same row)
    h1.appendChild(link);
    h1.dataset.pbcLinkAdded = '1';
  }

  // Add pbc.xxx search link next to video title
  function addVideoSearchLink() {
    if (!location.pathname.startsWith('/video/')) return;

    // Target the video title h1
    const h1 = document.querySelector(
      'h1.text-yellow-300, h1.text-center.text-2xl, h1.md\\:text-3xl'
    );
    if (!h1 || h1.dataset.pbcLinkAdded) return;

    const title = h1.textContent.trim();
    if (!title) return;

    const searchUrl = 'https://pbc.xxx/w/index.php?search=' + encodeURIComponent(title).replace(/%20/g, '+');

    const link = document.createElement('a');
    link.href = searchUrl;
    link.target = '_self';
    link.rel = 'noopener noreferrer';
    link.textContent = ' [PBC]';
    link.title = 'Search on pbc.xxx';
    link.style.cssText = 'margin-left: 0.5rem; font-size: 0.7em; color: #60a5fa; text-decoration: none; vertical-align: middle;';
    link.onmouseover = () => link.style.textDecoration = 'underline';
    link.onmouseout  = () => link.style.textDecoration = 'none';

    h1.appendChild(link);
    h1.dataset.pbcLinkAdded = '1';
  }

  // Runner
  function run() {
    setLengthTo100();
    selectHideCompilations();
    addPerformerSearchLink();
    addVideoSearchLink();
  }

  // Initial runs
  run();
  setTimeout(run, 400);
  setTimeout(run, 1200);
  setTimeout(run, 2500);

  // Watch for dynamic changes
  const observer = new MutationObserver(() => run());
  observer.observe(document.body, { childList: true, subtree: true });

  // DataTables redraw support
  if (window.jQuery) {
    jQuery(document).on('draw.dt', run);
  }
})();