XHamster Retired User Search (IA) (DuckDuckGo: In site search)

Ajoute un bouton de recherche pour les utilisateurs retirés sur XHamster

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         XHamster Retired User Search (IA) (DuckDuckGo: In site search)
// @namespace    http://tampermonkey.net/
// @version      3.0
// @description  Ajoute un bouton de recherche pour les utilisateurs retirés sur XHamster
// @author       Janvier56
// @match        https://*.xhamster.com/videos/*
// @icon         https://external-content.duckduckgo.com/ip3/fr.xhamster.com.ico
// @grant        GM_addStyle
// ==/UserScript==

(function() {
  'use strict';
  console.log('Script exécuté');
  GM_addStyle(`
    @import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css');
    .search-button {
      background: green;
      color: white;
      padding: 5px 10px;
      border: none;
      border-radius: 5px;
      cursor: pointer;
      display: flex;
      align-items: center;
    }
  `);
  var usernameElements = document.querySelectorAll('.video-page #video-tags-list-container > [class^="container-"] > [class^="list-"] [class^="item-"]:has([data-tooltip="User is retired"]) span');
  usernameElements.forEach(function(element) {
    var textContent = element.textContent.trim();
    var searchQuery = textContent;
    if (textContent.includes("##deleted_")) {
      searchQuery = textContent.replace("##deleted_", "");
    }
    console.log('ID/Name d\'utilisateur trouvé :', searchQuery);
    var searchButton = document.createElement('button');
    searchButton.className = 'search-button';
    searchButton.innerHTML = '<i class="fa fa-search" style="margin-right: 5px;"></i> <img src="https://duckduckgo.com/favicon.ico" width="16" height="16">';
    var url = 'https://duckduckgo.com/?q=' + encodeURIComponent(searchQuery + ' site:' + window.location.hostname.replace('www.', '')) + '&ia=web';
    searchButton.onmousedown = function(event) {
      if (event.button === 0) { // Clic gauche
        window.location.href = url;
      } else if (event.button === 1) { // Clic milieu
        window.open(url, '_blank');
      }
    };
    element.parentNode.appendChild(searchButton);
  });
})();