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 για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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