Xhamster Search Favs in Collection List v.4

Xhamster Search Favs in Collection List

当前为 2025-02-23 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Xhamster Search Favs in Collection List v.4
// @namespace    https://greasyfork.org/fr/users/7434-janvier56
// @version      4.0.0
// @description  Xhamster Search Favs in Collection List
// @icon         https://external-content.duckduckgo.com/ip3/fr.xhamster.com.ico
// @author       janvier57
// @include      https://xhamster.com/my/favorites/*
// @license      unlicense
// @grant        GM_addStyle
// ==/UserScript==

// ==UserScript==
// @name         Xhamster Search Favs in Collection List v.4
// @namespace    https://greasyfork.org/fr/users/7434-janvier56
// @version      2.0.0
// @description  Xhamster Search Favs in Collection List - in Your Collections and in Collections of other Users too
// @icon         https://external-content.duckduckgo.com/ip3/fr.xhamster.com.ico
// @author       janvier57
// @match      https://xhamster.com/my/favorites/*
// @match      https://*.xhamster.com/users/*/favorites/videos/*
// @license      unlicense
// @grant        GM_addStyle

// ==/UserScript==

(function() {
    'use strict';
    var searchInput = document.createElement('input');
    searchInput.type = 'search';
    searchInput.placeholder = 'Rechercher';
    searchInput.id = 'search-favs';

    var clearButton = document.createElement('button');
    clearButton.textContent = 'X';
    clearButton.id = 'clear-search';

    var searchContainer = document.createElement('div');
    searchContainer.appendChild(searchInput);
    searchContainer.appendChild(clearButton);

    // Attempt to find a target element in both structures
    var target1 = document.querySelector('.user-page.user-videos-page.my-uploads-page .side-column ul.submenu.submenu-video li:last-of-type');
    var target2 = document.querySelector('.user-page.favorites-page .favorites-side-switcher ul.video-collections-list li:last-of-type');
    var target = target1 || target2;

    if (target) {
        target.parentNode.insertBefore(searchContainer, target.nextSibling);
    }

    searchInput.addEventListener('input', function() {
        var filter = searchInput.value.toLowerCase();
        // Selectors for elements to filter, making it more adaptive
        var links1 = document.querySelectorAll('.user-page.user-videos-page.my-uploads-page .side-column ul.submenu li a');
        var links2 = document.querySelectorAll('.user-page.favorites-page .side-column ul.favorites-side-switcher li a + ul a:not(.edit-collection)');
        var links = [...links1, ...links2];

        links.forEach(function(link) {
            var text = link.textContent.toLowerCase();
            if (text.includes(filter)) {
                // Ensure the parent is visible
                link.parentNode.style.display = '';
                // Optionally, add a class for styling
                link.classList.add('match');
            } else {
                link.parentNode.style.display = 'none';
                link.classList.remove('match');
            }
        });
    });

    clearButton.addEventListener('click', function() {
        searchInput.value = '';
        // Reset visibility of all links
        var links1 = document.querySelectorAll('.side-column ul.submenu li');
        var links2 = document.querySelectorAll('.favorites-page .side-column ul.favorites-side-switcher li a + ul a:not(.edit-collection)');
        var links = [...links1, ...links2];

        links.forEach(function(link) {
            link.parentNode.style.display = '';
            link.classList.remove('match');
        });
    });

    // Include the styling from the first script, adjusting as necessary for compatibility
    GM_addStyle(`
        /* XHAM - GM "Xhamster Search Favs in Collection Liste v.1" */
        .width-wrap ,
        .main-wrap {
            max-width: 100%;
        }
        .side-column {
            position: relative;
            float: left;
            width: 300px ;
            padding-right: 31px;
            border-right: 1px solid silver;
        }
.user-page.user-videos-page.my-uploads-page .side-column > ul > li.active > ul ,
        .favorites-page .favorites-side-switcher ul.video-collections-list {
            min-height: 370px;
            max-height: 370px;
            background: #111;
            border: 1px solid silver;
            border-left: 3px solid red;
        }
.user-page.user-videos-page.my-uploads-page .side-column > ul > li.active > ul li a ,
        .favorites-page .side-column ul.submenu li a {
          color: silver ;
          display: inline-block;
          max-width: 245px;
          overflow: hidden;
          padding-right: 5px;
          text-overflow: ellipsis;
          vertical-align: middle;
        }
        .content-column {
          margin-left: 380px;
        }
        /* GM */
.user-page.user-videos-page.my-uploads-page .submenu.submenu-video li:last-of-type + div:has(#search-favs),
        .favorites-page .favorites-side-switcher ul.video-collections-list li:last-of-type + div:has(#search-favs) {
            position: fixed;
            display: inline-block;
            height: 2.9vh !important;
            width: 330px;
            bottom: 0.5vh;
            right: 1540px;
            z-index: 1;
            background: rgb(34, 34, 34);
            border: 1px solid azure;
        }
        /* HOVER */
.user-page.user-videos-page.my-uploads-page .submenu.submenu-video li:last-of-type + div:has(#search-favs):hover,
        .favorites-page .favorites-side-switcher ul.video-collections-list li:last-of-type + div:has(#search-favs):hover{
            background: green !important;
            border: 1px solid azure !important;
        }
.user-page.user-videos-page.my-uploads-page .submenu.submenu-video li:last-of-type + div:has(#search-favs) input#search-favs,
        .favorites-page .favorites-side-switcher ul.video-collections-list li:last-of-type + div:has(#search-favs) input#search-favs {
            position: relative  !important;
            display: inline-block;
            height: 2.5vh !important;
            width: 300px ;
            top: 0vh ;
            right: 0 ;
            z-index: 5000;
            color: gold;
            background: rgb(34, 34, 34);
            border: 1px solid azure;
        }
.user-page.user-videos-page.my-uploads-page .submenu.submenu-video li:last-of-type + div:has(#search-favs) button#clear-search,
        .favorites-page .favorites-side-switcher ul.video-collections-list li:last-of-type + div:has(#search-favs) button#clear-search {
            display: inline-block;
            height: 2.5vh !important;
            width: 20px;
            z-index: 5000;
            background: red;
            border: 1px solid azure;
        }
    `);
})();