Xhamster Search Favs in Collection List v.6

Xhamster Search Favs in Collection List - in Your Collections and in Collections of other Users too And Video page Collection list

// ==UserScript==
// @name         Xhamster Search Favs in Collection List v.6
// @namespace    https://greasyfork.org/fr/users/7434-janvier56
// @version      6.0.0
// @description  Xhamster Search Favs in Collection List - in Your Collections and in Collections of other Users too And Video page Collection list
// @icon         https://external-content.duckduckgo.com/ip3/fr.xhamster.com.ico
// @author       janvier57

// @match        https://*.xhamster.com/my/favorites/*
// @match        https://*.xhamster.*/my/favorites/*

// @match        https://*.xhamster.com/users/*/favorites/videos/*
// @match        https://*.xhamster.*/users/*/favorites/videos/*

// @match        https://*.xhamster.com/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');

    // VIDEO pages
    var target3 = document.querySelector('.video-page .dropdown.favorites-dropdown.position-left .favorites-dropdown__list');
    var target = target1 || target2 || target3;

    if (target1) {
        target1.parentNode.insertBefore(searchContainer, target1.nextSibling);
    } else if (target2) {
        target2.parentNode.insertBefore(searchContainer, target2.nextSibling);
    } else if (target3) {
        target3.appendChild(searchContainer);
    }

    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.submenu li a');
        // VIDEO pages
        var links3 = document.querySelectorAll('.video-page .favorites-control.xh-dropdown .dropdown .favorites-dropdown__list .favorites-dropdown__list-item span.favorites-dropdown__list-title');
        var links = [...links1, ...links2, ...links3];

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

        links.forEach(function(link) {
            var text;
            if (link.tagName === 'A') {
                text = link.textContent.toLowerCase();
            } else if (link.tagName === 'SPAN' && link.classList.contains('favorites-dropdown__list-title')) {
                text = link.textContent.toLowerCase();
            } else {
                return;
            }

            if (text.includes(filter)) {
                // Ensure the parent is visible
                link.parentNode.style.display = '';
                // Add the .match class
                link.classList.add('match');
            } else {
                link.parentNode.style.display = 'none';
                // Remove the .match class
                link.classList.remove('match');
            }
        });
    });

    searchInput.addEventListener('keydown', function(event) {
        if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
            event.preventDefault();
        }
    });

    clearButton.addEventListener('click', function() {
        searchInput.value = '';
        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.submenu li a');
        // VIDEO pages
        var links3 = document.querySelectorAll('.video-page .favorites-control.xh-dropdown .dropdown .favorites-dropdown__list .favorites-dropdown__list-item span.favorites-dropdown__list-title');
        var links = [...links1, ...links2, ...links3];

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

    GM_addStyle(`

/* XHAM - GM "Xhamster Search Favs in Collection Liste v.6 -  VIDEO PAGE - TEST FOR just GM  */


/*  === REGEX XHAM VIDEO PAGES  (IA) ====
This pattern should now match URLs like:

https://xhamster.com/videos/
http://www.xhamster.fr/videos/
https://fra.xhamster.com/videos/
http://xhamster.xxx/videos/
https://xhamster.net/videos/
https://xhamster.com/videos/some-video
http://fra.xhamster.fr/videos/another-video

==== */
/* WIDTH CONTAINER - OTHER PAGE */
.width-wrap ,
.main-wrap {
	max-width: 100%;
}
/* WIDTH CONTAINER - VIDEO PAGE */
.video-page .width-wrap ,
.video-page .main-wrap {
	max-width: 87%;
}

/* FAVS COLUMN */
.side-column {
	position: relative;
	float: left;
	width: 300px ;
	padding-right: 31px;
border-right: 1px solid silver;
}
/* FAVS LIST */
.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 {
	display: inline-block;
	max-width: 245px;
	vertical-align: middle;
	padding-right: 5px;
	text-overflow: ellipsis;
	overflow: hidden;
color: silver ;
}
.content-column {
	margin-left: 380px;
}
/* GM */

/* MY and USERS FAVS */
.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;
}

/* FAVS VIDEO PAGES */
/*LIST */
.video-page:has(#search-favs) .dropdown.favorites-dropdown.position-left .favorites-dropdown__list .items  {
	position: fixed ;
	display: inline-block ;
	height: 82.9vh ;
	width: 330px ;
	bottom: 2.5vh;
	right: 0px;
	overflow: hidden auto;
	visibility: visible !important;
	z-index: 80000000 !important;
background: rgb(34, 34, 34);
border: 1px solid azure;
}
.video-page:has(#search-favs) .dropdown.favorites-dropdown.position-left .favorites-dropdown__list .items li span.favorites-dropdown__list-title  {
	display: inline-block;
	max-width: 245px;
	vertical-align: middle;
	padding-right: 5px;
	text-overflow: ellipsis;
	overflow: hidden;
color: silver ;
border: 1px solid azure;
}
/* FORM */
.video-page:has(#search-favs) .dropdown.favorites-dropdown.position-left .favorites-dropdown__list div:has(#search-favs) {
	position: fixed !important;
	display: inline-block !important;
	height: 2.9vh ;
	width: 330px ;
	bottom: 0.5vh ;
	right: 0px !important;
	visibility: visible ;
	z-index: 80000000 ;
background: rgb(34, 34, 34);
border: 1px solid azure;
}


/* HOVER */
.video-page:has(#search-favs) .dropdown.favorites-dropdown.position-left .favorites-dropdown__list div:has(#search-favs).dropdown.favorites-dropdown.position-left .favorites-dropdown__list .items li:last-of-type + div:has(#search-favs):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;
}

.video-page:has(#search-favs) .dropdown.favorites-dropdown.position-left .favorites-dropdown__list div:has(#search-favs) input#search-favs,

.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;
}
.video-page:has(#search-favs) .dropdown.favorites-dropdown.position-left .favorites-dropdown__list div:has(#search-favs) button#clear-search,

.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;
}
input#search-favs::-webkit-search-cancel-button {
            display: none;
    }
`);
})();