Sleazy Fork is available in English.

IAFD Scene Pairings Search Filter

Add a filter for the paring pages

  1. // ==UserScript==
  2. // @name IAFD Scene Pairings Search Filter
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Add a filter for the paring pages
  6. // @icon https://www.iafd.com/favicon-196x196.png
  7. // @author Janvier57
  8. // @match https://www.iafd.com/person.rme/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. // Fonction pour créer le filtre de recherche
  15. function createSearchFilter() {
  16. // Sélectionner l'iframe #scpr
  17. var iframe = document.getElementById('scpr');
  18.  
  19. // Attendez que l'iframe soit chargé
  20. iframe.addEventListener('load', function() {
  21. // Accéder au contenu de l'iframe
  22. var iframeContent = iframe.contentDocument;
  23.  
  24. // Intégrer Font Awesome
  25. var link = iframeContent.createElement('link');
  26. link.rel = 'stylesheet';
  27. link.href = 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css';
  28. iframeContent.head.appendChild(link);
  29.  
  30. // Sélectionner l'élément .container à l'intérieur de l'iframe
  31. var container = iframeContent.querySelector('.container');
  32.  
  33. // Créer le conteneur pour le filtre total
  34. var filterTotalContainer = iframeContent.createElement('div');
  35. filterTotalContainer.classList.add('filter-total');
  36.  
  37. // Créer l'élément de recherche pour le filtre total
  38. var searchInputTotal = iframeContent.createElement('input');
  39. searchInputTotal.type = 'search';
  40. searchInputTotal.placeholder = 'Rechercher...';
  41. searchInputTotal.classList.add('search-filter');
  42.  
  43. // Créer le label pour l'élément de recherche pour le filtre total
  44. var searchLabelTotal = iframeContent.createElement('label');
  45. searchLabelTotal.textContent = 'Filter Total ';
  46. searchLabelTotal.innerHTML += '<i class="fas fa-search"></i>';
  47. searchLabelTotal.appendChild(searchInputTotal);
  48.  
  49. // Créer le bouton "X" pour effacer le filtre total
  50. var clearButtonTotal = iframeContent.createElement('button');
  51. clearButtonTotal.textContent = 'X';
  52. clearButtonTotal.classList.add('clear-button');
  53.  
  54. // Ajouter l'élément de recherche et le bouton "X" dans le conteneur
  55. filterTotalContainer.appendChild(searchLabelTotal);
  56. filterTotalContainer.appendChild(clearButtonTotal);
  57.  
  58. // Ajouter le conteneur au début du conteneur principal
  59. container.insertBefore(filterTotalContainer, container.firstChild);
  60.  
  61. // Fonction pour filtrer les résultats pour le filtre total
  62. searchInputTotal.addEventListener('input', function() {
  63. var searchTerm = this.value.toLowerCase();
  64. var rows = container.querySelectorAll('.row');
  65.  
  66. rows.forEach(function(row) {
  67. var matchupaka = row.querySelector('.matchupaka');
  68. var matchuph3 = row.querySelector('.matchuph3');
  69. var matchupText = (matchupaka ? matchupaka.textContent : '') + (matchuph3 ? matchuph3.textContent : '');
  70. matchupText = matchupText.toLowerCase();
  71.  
  72. if (matchupText.includes(searchTerm)) {
  73. row.style.display = 'block';
  74. } else {
  75. row.style.display = 'none';
  76. }
  77. });
  78. });
  79.  
  80. // Fonction pour effacer le filtre total
  81. clearButtonTotal.addEventListener('click', function() {
  82. searchInputTotal.value = '';
  83. var rows = container.querySelectorAll('.row');
  84. rows.forEach(function(row) {
  85. row.style.display = 'block';
  86. });
  87.  
  88. // Réinitialiser les valeurs des autres éléments de recherche
  89. var searchInputs = container.querySelectorAll('.search-filter');
  90. searchInputs.forEach(function(searchInput) {
  91. searchInput.value = '';
  92. });
  93.  
  94. // Réafficher les éléments .row correspondants
  95. var h2s = container.querySelectorAll('h2');
  96. h2s.forEach(function(h2) {
  97. var nextH2 = h2.nextElementSibling;
  98. while (nextH2 && nextH2.tagName !== 'H2') {
  99. if (nextH2.classList.contains('row')) {
  100. nextH2.style.display = 'block';
  101. }
  102. nextH2 = nextH2.nextElementSibling;
  103. }
  104. });
  105. });
  106.  
  107. // Sélectionner les h2
  108. var h2s = container.querySelectorAll('h2');
  109.  
  110. // Créer un élément de recherche pour chaque h2
  111. h2s.forEach(function(h2) {
  112. var filterContainer = iframeContent.createElement('div');
  113. filterContainer.classList.add('filter-particular');
  114.  
  115. var searchInput = iframeContent.createElement('input');
  116. searchInput.type = 'search';
  117. searchInput.placeholder = 'Rechercher...';
  118. searchInput.classList.add('search-filter');
  119.  
  120. // Créer le label pour l'élément de recherche
  121. var searchLabel = iframeContent.createElement('label');
  122. searchLabel.innerHTML = '<i class="fas fa-search"></i> ' + h2.textContent + ' ';
  123. searchLabel.appendChild(searchInput);
  124.  
  125. // Créer le bouton "X" pour effacer le filtre
  126. var clearButton = iframeContent.createElement('button');
  127. clearButton.textContent = 'X';
  128. clearButton.classList.add('clear-button');
  129.  
  130. // Ajouter l'élément de recherche et le bouton "X" dans le conteneur
  131. filterContainer.appendChild(searchLabel);
  132. filterContainer.appendChild(clearButton);
  133.  
  134. // Ajouter le conteneur après le h2
  135. h2.parentNode.insertBefore(filterContainer, h2.nextSibling);
  136.  
  137. // Fonction pour filtrer les résultats
  138. searchInput.addEventListener('input', function() {
  139. var searchTerm = this.value.toLowerCase();
  140. var nextH2 = h2.nextElementSibling;
  141. while (nextH2 && nextH2.tagName !== 'H2') {
  142. if (nextH2.classList.contains('row')) {
  143. var matchupaka = nextH2.querySelector('.matchupaka');
  144. var matchuph3 = nextH2.querySelector('.matchuph3');
  145. var matchupText = (matchupaka ? matchupaka.textContent : '') + (matchuph3 ? matchuph3.textContent : '');
  146. matchupText = matchupText.toLowerCase();
  147.  
  148. if (matchupText.includes(searchTerm)) {
  149. nextH2.style.display = 'block';
  150. } else {
  151. nextH2.style.display = 'none';
  152. }
  153. }
  154. nextH2 = nextH2.nextElementSibling;
  155. }
  156. });
  157.  
  158. // Fonction pour effacer le filtre
  159. clearButton.addEventListener('click', function() {
  160. searchInput.value = '';
  161. var nextH2 = h2.nextElementSibling;
  162. while (nextH2 && nextH2.tagName !== 'H2') {
  163. if (nextH2.classList.contains('row')) {
  164. nextH2.style.display = 'block';
  165. }
  166. nextH2 = nextH2.nextElementSibling;
  167. }
  168.  
  169. // Réinitialiser la valeur de l'élément de recherche total
  170. searchInputTotal.value = '';
  171.  
  172. // Réafficher tous les éléments .row
  173. var rows = container.querySelectorAll('.row');
  174. rows.forEach(function(row) {
  175. row.style.display = 'block';
  176. });
  177. });
  178. });
  179. });
  180. }
  181.  
  182. // Appeler la fonction pour créer le filtre de recherche
  183. createSearchFilter();
  184. })();