Erome.com Improved

Infinite scroll. Filter photo albums. Show/hide photos in albums.

Mint 2024.04.27.. Lásd a legutóbbi verzió

  1. // ==UserScript==
  2. // @name Erome.com Improved
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2
  5. // @license MIT
  6. // @description Infinite scroll. Filter photo albums. Show/hide photos in albums.
  7. // @author smartacephale
  8. // @match *://*.erome.com/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=erome.com
  10. // @run-at document-end
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. const LOGO = `
  15. ⡠⢡⠨⡠⢡⠨⡠⢡⠨⡠⢡⠨⡠⢡⠨⡠⢡⠨⡠⢡⠨⡠⢡⠨⡐⠜⠔⠎⠖⠜⠔⠎⠖⠜⠔⠎⠖⠜⠔⠎⠖⠜⠔⠎⠖⠜⠔⠎⠖⠜
  16. ⣐⢂⡒⣂⢒⢂⡒⣂⢒⢂⡒⣂⢒⢂⡒⣂⢒⢂⡒⣂⢒⢂⡒⡒⡐⡍⡍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍
  17. ⡆⡇⡕⡜⡜⡌⡎⡆⡇⡇⡕⡜⡜⡌⡎⡆⡇⡇⡕⡜⡜⡌⡎⡜⡜⠌⠎⠜⠔⠕⠌⠦⠱⠌⠦⠱⠌⠦⠱⠌⠦⠱⠌⠦⠱⠌⠦⠱⠌⠆
  18. ⣈⣂⣑⣈⢂⡊⣂⢒⣈⢂⡊⣂⢊⡂⣊⡐⣂⢊⡂⣑⡐⣑⢈⣂⢊⠥⢭⢱⢩⠬⠭⠬⠥⠭⠬⠥⠭⠬⠥⠭⠬⠥⠭⠬⠥⠭⠬⠥⡍⡎
  19. ⠕⡐⢔⢂⢃⡊⣂⢃⡂⣃⢊⡂⣃⢊⡂⣊⢂⡃⣊⢂⡊⣂⢃⡂⡣⡱⡡⡪⠔⡅⡇⠭⡪⠥⢍⢎⠥⢍⢎⠥⢍⢎⠥⢍⢎⠥⢍⢎⢔⠥
  20. ⡕⡕⡕⣜⢔⢎⢆⢇⢎⢆⢇⢎⢆⢇⢎⢆⢇⢎⢆⢇⢎⢆⢇⢎⢖⢐⠐⡈⠌⡐⠨⢈⠄⠅⡂⡂⠅⡁⡂⠡⢁⢂⠡⢁⢂⠡⢁⠂⡂⡁
  21. ⢳⢑⣓⡒⡇⡳⡑⡇⡳⡑⡇⡳⡑⡇⡳⡑⡇⡳⡑⡇⡳⡑⡇⡳⡱⡠⡡⢡⠡⡨⡨⠄⡅⢅⠌⡄⠥⡨⠨⡨⡠⡡⠨⢄⠅⡌⠤⡡⡨⡠
  22. ⡣⣑⢢⢑⢅⢣⢑⡑⡅⡣⣑⣑⡑⣑⢅⢣⢑⡑⡅⡣⣑⣑⡑⡅⡣⠱⠸⠌⠮⠸⠨⠪⠪⠜⠜⠬⠱⠌⠇⢕⠬⠪⠩⠪⠜⠬⠱⠱⠨⡢
  23. ⢔⠢⡃⢎⠢⠣⢒⠱⡘⢔⠢⠢⡊⠆⢎⠢⠣⡊⢆⠣⡒⠔⡢⢃⠎⢕⠝⡸⡘⢕⠍⢇⠫⢪⠱⡙⢜⠱⡙⢜⠸⡘⢍⢎⠣⡹⡘⢕⠍⢎
  24. ⢔⢑⠜⡂⢝⢘⡘⣘⢘⡐⢍⢊⠪⡑⣑⢑⡑⣑⢑⢑⡘⣘⢘⡐⢍⠦⡱⡡⡪⡢⠭⠬⡪⠬⡪⢌⢎⠬⡪⢌⢎⢜⢌⠦⡱⡡⡪⡢⠭⢌
  25. ⡢⡱⡨⣊⢆⢕⢔⡢⡱⡨⡢⡱⣑⢌⢆⡲⡨⡢⣊⢆⡪⡢⡒⡌⣆⠣⡃⠇⡣⠣⠍⢇⠣⠹⡘⠜⠜⠜⠜⠜⠜⡸⠘⢜⠸⢘⠌⠎⠍⠎
  26. ⢇⢕⢕⢢⢣⢱⢑⢌⢎⢜⢌⢎⢆⢣⢱⢸⢨⠪⡢⡱⢌⢆⢇⢇⠦⡡⡨⢨⠠⡡⡡⢡⠡⡑⠌⡌⢌⢌⢌⢌⢌⢄⠍⡄⢅⠅⢅⠍⢌⠅
  27. ⢕⢅⢇⢕⢅⢇⢕⠕⡅⡇⡕⢥⢱⢡⢣⢱⢡⢣⢱⢑⢕⠥⡱⡡⡣⢱⠸⠸⡘⡌⢎⠜⡌⢎⠕⠕⡅⢇⠅⡇⠎⢆⠇⢇⢣⠹⡨⠪⠪⠪
  28. ⡐⡑⡐⡑⡐⡑⡐⡑⢌⢂⡊⣂⢑⡐⡑⣐⢑⢐⢑⡈⡢⡑⣈⢂⡊⡎⢎⠇⡇⡎⡎⡎⢎⠖⡕⡕⡕⡕⢕⢕⠝⡔⡕⡕⢕⢕⢪⢹⠸⡙
  29. ⠕⠕⢕⠕⢕⠕⠕⠝⠜⠜⠜⠜⠜⠜⠜⠜⠜⠜⠜⠜⠜⠜⠜⠜⢌⢆⢅⢎⢔⢔⢔⢌⢆⢅⠦⢬⢰⠨⡔⢤⢱⢰⢨⢰⢡⢢⢡⢢⢱⢨
  30. ⡜⣘⢔⢅⢣⢊⢎⢪⢊⢎⢪⢊⡪⡊⡎⡪⡊⡎⡪⡊⡎⡪⣊⢪⢂⢇⠕⡅⢇⢎⠪⡢⡃⢇⠣⡣⢱⢑⠕⢕⠅⡇⢕⠱⡡⢣⠱⡑⡅⢇
  31. ⡒⡔⡲⡸⡰⡑⡆⢇⢎⢆⢣⢒⢆⢣⢪⢒⢜⢔⢕⢜⢔⢜⢔⢜⢔⠅⠇⠎⢆⠣⠱⡘⠌⢎⠪⠸⠰⠡⠣⠣⠱⠸⡘⠜⠌⠆⠇⠕⠜⠔
  32. ⢃⢃⠣⡊⡢⢃⠎⡊⢆⢃⢃⠣⡊⡪⢂⠣⡊⡢⢃⢒⠱⡘⢔⢑⠢⡣⡣⡍⡆⡇⡇⡕⡍⡆⡇⡝⡌⡇⡝⡌⡇⡇⡎⡎⡎⡕⡍⡎⡕⡕
  33. ⡕⡱⡱⢸⠰⡱⡸⢸⠰⡑⡕⢕⠜⡔⢕⠕⡜⢔⠕⡕⡱⡸⡰⡑⡕⢌⠆⢕⠡⡱⢘⢌⠪⡨⢊⢌⠪⡘⢌⠪⡨⢊⠢⡱⢘⠌⡪⡘⢌⢊
  34. ⣒⢌⢆⢣⢑⢢⠪⡂⡇⢕⢌⢆⢣⢊⢆⢣⢊⢆⢣⢊⢆⢒⢢⠱⡘⢔⠍⡜⢌⠎⡌⢆⢣⠱⡡⡱⢡⠣⡱⠱⡘⡌⢎⠜⢔⠕⡱⡘⡌⢆
  35. ⢔⢕⢜⢔⢕⠕⡕⢕⢜⢜⢔⢕⢜⢔⢕⢜⢔⢕⢪⢢⠣⡣⢣⠣⡣⡑⠕⢌⠆⡣⡑⢅⠥⠱⡨⠌⢆⠕⠜⢌⠪⡨⠢⡩⠢⡱⠨⠢⢪⠨
  36. ⢣⢊⠆⡕⢌⠎⡜⢌⢆⢕⢌⢆⠕⡌⡆⡕⠜⡌⢆⠕⡅⡣⡱⡑⢅⢣⢍⢆⢣⢱⢘⢌⢪⢱⢘⢜⢌⢪⢱⢡⠣⡪⡱⡨⡱⡸⡨⢍⢆⢣
  37. ⢪⢂⢇⠣⡣⡑⡕⡱⡨⡢⡱⡘⡌⡪⡂⢇⢣⠱⣑⢱⠡⡃⡎⢜⢸⢐⠕⡌⡪⢢⠱⡡⢣⢡⠱⡡⢪⠸⡐⡅⡣⡱⢨⠪⡨⢢⠱⡡⡱⢡
  38. ⡌⢆⢣⠱⡡⡱⡘⡌⢆⢕⠜⢌⢪⢘⢌⢎⢊⢎⢢⠱⡑⡅⡣⢣⢑⢅⢇⢪⢸⠰⡱⢸⠰⡡⡣⢱⠡⡣⡱⡘⡔⡱⡡⢣⠱⡡⡣⡱⡘⡌
  39. ⠪⡊⢆⢣⠱⡨⡢⢣⢑⢢⢃⢇⢕⠱⡨⢢⢃⢎⠢⡣⢱⢘⢌⢆⢣⢊⢆⢣⢡⠣⡪⢪⠸⡐⡕⢅⠇⡕⡌⢎⢌⢆⢣⠱⡑⡱⡨⢢⠣⡱`;
  40. console.log(LOGO);
  41.  
  42. function togglePhotoElements(){
  43. Array.from(document.querySelectorAll('.media-group')).forEach(a => {
  44. if (!a.querySelector('.video')) {
  45. if (config.showPhotos) {
  46. $(a.parentElement).css("display", "block");
  47. } else {
  48. $(a.parentElement).css("display", "none");
  49. }
  50. }
  51. });
  52. }
  53.  
  54. function hidePhotoOnlyAlbums() {
  55. const albumsContainers = document.querySelectorAll('#albums');
  56. albumsContainers.forEach(a => {
  57. Array.from(a.children).forEach(a => {
  58. if (!a.querySelector('.album-videos')) {
  59. if (config.showPhotoAlbums) {
  60. $(a).show();
  61. } else {
  62. $(a).hide();
  63. }
  64. }
  65. });
  66. });
  67. }
  68.  
  69. function infiniteScrollAndLazyLoading() {
  70. // taken from index.html of erome mobile version
  71. const curPage = window.location.search.match(/page=(\d+)/);
  72. var next_page = (curPage ? parseInt(curPage[1]) : 1) + 1;
  73.  
  74. var infinite = $('#page').infiniteScroll({
  75. path: function() {
  76. const { pathname, search } = window.location;
  77. const page = `page=${next_page}`;
  78. let query = "";
  79. if (search) {
  80. if (/page=/.test(search)) {
  81. query = search.replace(/page=(\d+)/, () => page);
  82. } else {
  83. query = `${search}&${page}`;
  84. }
  85. } else {
  86. query = `?${page}`;
  87. }
  88. console.log(pathname, query)
  89. return pathname + query;
  90. },
  91. append: '.page-content',
  92. scrollThreshold: 800
  93. });
  94.  
  95. $('#page').on('append.infiniteScroll', function(event, body, path, items, response) {
  96. hidePhotoOnlyAlbums();
  97. new LazyLoad();
  98. scrollFix();
  99. next_page = next_page + 1;
  100. if(next_page > 50 || next_page > 50){
  101. infinite.destroy();
  102. }
  103. });
  104. }
  105.  
  106. function scrollFix() {
  107. setTimeout(() => window.dispatchEvent(new Event('scroll')), 1000);
  108. }
  109.  
  110. const DEFAULT_CONFIG = {
  111. showPhotos: false,
  112. showPhotoAlbums: false
  113. };
  114.  
  115. const stored = localStorage.getItem("config");
  116. const config = JSON.parse(stored) || DEFAULT_CONFIG;
  117.  
  118.  
  119. (function() {
  120. 'use strict';
  121.  
  122. if (/^\/a\//.test(window.location.pathname)) {
  123. togglePhotoElements();
  124. $('#user_name').parent().append('<button id="togglePhotos" class="btn btn-pink user-hide">show/hide photos</button>');
  125. $('#togglePhotos').on('click', () => {
  126. config.showPhotos = !config.showPhotos;
  127. localStorage.setItem("config", JSON.stringify(config));
  128. togglePhotoElements();
  129. });
  130. } else {
  131. hidePhotoOnlyAlbums();
  132. infiniteScrollAndLazyLoading();
  133. $('.navbar-nav').append('<li><a href="#" id="togglePhotoAlbums">video only</span></a></li>');
  134. $('#togglePhotoAlbums').css('color', !config.showPhotoAlbums ? '#eb6395' : '#a09f9d');
  135. $('#togglePhotoAlbums').on('click', () => {
  136. config.showPhotoAlbums = !config.showPhotoAlbums;
  137. localStorage.setItem("config", JSON.stringify(config));
  138. hidePhotoOnlyAlbums();
  139. $('#togglePhotoAlbums').css('color', !config.showPhotoAlbums ? '#eb6395' : '#a09f9d');
  140. });
  141. }
  142.  
  143. scrollFix();
  144. })();