Erome Filter

Filter images and videos in Erome

  1. // ==UserScript==
  2. // @name Erome Filter
  3. // @version 1.0
  4. // @description Filter images and videos in Erome
  5. // @match https://www.erome.com/a/*
  6. // @icon https://www.erome.com/favicon.ico
  7. // @grant none
  8. // @namespace https://greasyfork.org/users/1030442
  9. // ==/UserScript==
  10.  
  11. const albumElement = document.querySelector('[id^="album_"]');
  12. const videoDivs = albumElement.querySelectorAll('div > div > .video');
  13. const imageDivs = albumElement.querySelectorAll('div > div > div > img.img-front');
  14.  
  15. if (videoDivs.length > 0 && imageDivs.length > 0) {
  16. const userInfoElement = document.querySelector('.user-info.text-right');
  17. const selectElement = document.createElement('select');
  18. const options = [
  19. { value: 'all', text: `Show All (${imageDivs.length + videoDivs.length})` },
  20. { value: 'images', text: `Show Images (${imageDivs.length})` },
  21. { value: 'videos', text: `Show Videos (${videoDivs.length})` },
  22. ];
  23.  
  24. selectElement.addEventListener('change', function() {
  25. const selectedOption = this.value;
  26. if (selectedOption === 'images') {
  27. videoDivs.forEach(div => div.parentElement.parentElement.style.display = 'none');
  28. imageDivs.forEach(div => div.parentElement.parentElement.parentElement.style.display = '');
  29. }
  30. if (selectedOption === 'videos') {
  31. videoDivs.forEach(div => div.parentElement.parentElement.style.display = '');
  32. imageDivs.forEach(div => div.parentElement.parentElement.parentElement.style.display = 'none');
  33. }
  34. if (selectedOption === 'all') {
  35. imageDivs.forEach(div => div.parentElement.parentElement.parentElement.style.display = '');
  36. videoDivs.forEach(div => div.parentElement.parentElement.style.display = '');
  37. }
  38. });
  39.  
  40. options.forEach(option => {
  41. const { value, text } = option;
  42. const optionElement = document.createElement('option');
  43. optionElement.value = value;
  44. optionElement.text = text;
  45. selectElement.appendChild(optionElement);
  46. });
  47.  
  48. userInfoElement.prepend(selectElement);
  49. }