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.

Вам потребуется установить расширение, например Tampermonkey или Violentmonkey, чтобы установить этот скрипт.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Violentmonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Userscripts.

Чтобы установить этот скрипт, сначала вы должны установить расширение браузера, например Tampermonkey.

Чтобы установить этот скрипт, вы должны установить расширение — менеджер скриптов.

(у меня уже есть менеджер скриптов, дайте мне установить скрипт!)

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

(у меня уже есть менеджер стилей, дайте мне установить скрипт!)

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