erome infinite scroll & filter video albums only, show/hide photos in albums

Erome infinite scroll. Filter video albums only, button at top right on navbar. Show/hide photos in albums button.

Versione datata 19/04/2024. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         erome infinite scroll & filter video albums only, show/hide photos in albums
// @namespace    http://tampermonkey.net/
// @version      1.0
// @license      MIT
// @description  Erome infinite scroll. Filter video albums only, button at top right on navbar. Show/hide photos in albums button.
// @author       smartacephale
// @match        *://*.erome.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=erome.com
// @run-at       document-end
// @grant        none
// ==/UserScript==

const LOGO = `
⡠⢡⠨⡠⢡⠨⡠⢡⠨⡠⢡⠨⡠⢡⠨⡠⢡⠨⡠⢡⠨⡠⢡⠨⡐⠜⠔⠎⠖⠜⠔⠎⠖⠜⠔⠎⠖⠜⠔⠎⠖⠜⠔⠎⠖⠜⠔⠎⠖⠜
⣐⢂⡒⣂⢒⢂⡒⣂⢒⢂⡒⣂⢒⢂⡒⣂⢒⢂⡒⣂⢒⢂⡒⡒⡐⡍⡍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍⢍
⡆⡇⡕⡜⡜⡌⡎⡆⡇⡇⡕⡜⡜⡌⡎⡆⡇⡇⡕⡜⡜⡌⡎⡜⡜⠌⠎⠜⠔⠕⠌⠦⠱⠌⠦⠱⠌⠦⠱⠌⠦⠱⠌⠦⠱⠌⠦⠱⠌⠆
⣈⣂⣑⣈⢂⡊⣂⢒⣈⢂⡊⣂⢊⡂⣊⡐⣂⢊⡂⣑⡐⣑⢈⣂⢊⠥⢭⢱⢩⠬⠭⠬⠥⠭⠬⠥⠭⠬⠥⠭⠬⠥⠭⠬⠥⠭⠬⠥⡍⡎
⠕⡐⢔⢂⢃⡊⣂⢃⡂⣃⢊⡂⣃⢊⡂⣊⢂⡃⣊⢂⡊⣂⢃⡂⡣⡱⡡⡪⠔⡅⡇⠭⡪⠥⢍⢎⠥⢍⢎⠥⢍⢎⠥⢍⢎⠥⢍⢎⢔⠥
⡕⡕⡕⣜⢔⢎⢆⢇⢎⢆⢇⢎⢆⢇⢎⢆⢇⢎⢆⢇⢎⢆⢇⢎⢖⢐⠐⡈⠌⡐⠨⢈⠄⠅⡂⡂⠅⡁⡂⠡⢁⢂⠡⢁⢂⠡⢁⠂⡂⡁
⢳⢑⣓⡒⡇⡳⡑⡇⡳⡑⡇⡳⡑⡇⡳⡑⡇⡳⡑⡇⡳⡑⡇⡳⡱⡠⡡⢡⠡⡨⡨⠄⡅⢅⠌⡄⠥⡨⠨⡨⡠⡡⠨⢄⠅⡌⠤⡡⡨⡠
⡣⣑⢢⢑⢅⢣⢑⡑⡅⡣⣑⣑⡑⣑⢅⢣⢑⡑⡅⡣⣑⣑⡑⡅⡣⠱⠸⠌⠮⠸⠨⠪⠪⠜⠜⠬⠱⠌⠇⢕⠬⠪⠩⠪⠜⠬⠱⠱⠨⡢
⢔⠢⡃⢎⠢⠣⢒⠱⡘⢔⠢⠢⡊⠆⢎⠢⠣⡊⢆⠣⡒⠔⡢⢃⠎⢕⠝⡸⡘⢕⠍⢇⠫⢪⠱⡙⢜⠱⡙⢜⠸⡘⢍⢎⠣⡹⡘⢕⠍⢎
⢔⢑⠜⡂⢝⢘⡘⣘⢘⡐⢍⢊⠪⡑⣑⢑⡑⣑⢑⢑⡘⣘⢘⡐⢍⠦⡱⡡⡪⡢⠭⠬⡪⠬⡪⢌⢎⠬⡪⢌⢎⢜⢌⠦⡱⡡⡪⡢⠭⢌
⡢⡱⡨⣊⢆⢕⢔⡢⡱⡨⡢⡱⣑⢌⢆⡲⡨⡢⣊⢆⡪⡢⡒⡌⣆⠣⡃⠇⡣⠣⠍⢇⠣⠹⡘⠜⠜⠜⠜⠜⠜⡸⠘⢜⠸⢘⠌⠎⠍⠎
⢇⢕⢕⢢⢣⢱⢑⢌⢎⢜⢌⢎⢆⢣⢱⢸⢨⠪⡢⡱⢌⢆⢇⢇⠦⡡⡨⢨⠠⡡⡡⢡⠡⡑⠌⡌⢌⢌⢌⢌⢌⢄⠍⡄⢅⠅⢅⠍⢌⠅
⢕⢅⢇⢕⢅⢇⢕⠕⡅⡇⡕⢥⢱⢡⢣⢱⢡⢣⢱⢑⢕⠥⡱⡡⡣⢱⠸⠸⡘⡌⢎⠜⡌⢎⠕⠕⡅⢇⠅⡇⠎⢆⠇⢇⢣⠹⡨⠪⠪⠪
⡐⡑⡐⡑⡐⡑⡐⡑⢌⢂⡊⣂⢑⡐⡑⣐⢑⢐⢑⡈⡢⡑⣈⢂⡊⡎⢎⠇⡇⡎⡎⡎⢎⠖⡕⡕⡕⡕⢕⢕⠝⡔⡕⡕⢕⢕⢪⢹⠸⡙
⠕⠕⢕⠕⢕⠕⠕⠝⠜⠜⠜⠜⠜⠜⠜⠜⠜⠜⠜⠜⠜⠜⠜⠜⢌⢆⢅⢎⢔⢔⢔⢌⢆⢅⠦⢬⢰⠨⡔⢤⢱⢰⢨⢰⢡⢢⢡⢢⢱⢨
⡜⣘⢔⢅⢣⢊⢎⢪⢊⢎⢪⢊⡪⡊⡎⡪⡊⡎⡪⡊⡎⡪⣊⢪⢂⢇⠕⡅⢇⢎⠪⡢⡃⢇⠣⡣⢱⢑⠕⢕⠅⡇⢕⠱⡡⢣⠱⡑⡅⢇
⡒⡔⡲⡸⡰⡑⡆⢇⢎⢆⢣⢒⢆⢣⢪⢒⢜⢔⢕⢜⢔⢜⢔⢜⢔⠅⠇⠎⢆⠣⠱⡘⠌⢎⠪⠸⠰⠡⠣⠣⠱⠸⡘⠜⠌⠆⠇⠕⠜⠔
⢃⢃⠣⡊⡢⢃⠎⡊⢆⢃⢃⠣⡊⡪⢂⠣⡊⡢⢃⢒⠱⡘⢔⢑⠢⡣⡣⡍⡆⡇⡇⡕⡍⡆⡇⡝⡌⡇⡝⡌⡇⡇⡎⡎⡎⡕⡍⡎⡕⡕
⡕⡱⡱⢸⠰⡱⡸⢸⠰⡑⡕⢕⠜⡔⢕⠕⡜⢔⠕⡕⡱⡸⡰⡑⡕⢌⠆⢕⠡⡱⢘⢌⠪⡨⢊⢌⠪⡘⢌⠪⡨⢊⠢⡱⢘⠌⡪⡘⢌⢊
⣒⢌⢆⢣⢑⢢⠪⡂⡇⢕⢌⢆⢣⢊⢆⢣⢊⢆⢣⢊⢆⢒⢢⠱⡘⢔⠍⡜⢌⠎⡌⢆⢣⠱⡡⡱⢡⠣⡱⠱⡘⡌⢎⠜⢔⠕⡱⡘⡌⢆
⢔⢕⢜⢔⢕⠕⡕⢕⢜⢜⢔⢕⢜⢔⢕⢜⢔⢕⢪⢢⠣⡣⢣⠣⡣⡑⠕⢌⠆⡣⡑⢅⠥⠱⡨⠌⢆⠕⠜⢌⠪⡨⠢⡩⠢⡱⠨⠢⢪⠨
⢣⢊⠆⡕⢌⠎⡜⢌⢆⢕⢌⢆⠕⡌⡆⡕⠜⡌⢆⠕⡅⡣⡱⡑⢅⢣⢍⢆⢣⢱⢘⢌⢪⢱⢘⢜⢌⢪⢱⢡⠣⡪⡱⡨⡱⡸⡨⢍⢆⢣
⢪⢂⢇⠣⡣⡑⡕⡱⡨⡢⡱⡘⡌⡪⡂⢇⢣⠱⣑⢱⠡⡃⡎⢜⢸⢐⠕⡌⡪⢢⠱⡡⢣⢡⠱⡡⢪⠸⡐⡅⡣⡱⢨⠪⡨⢢⠱⡡⡱⢡
⡌⢆⢣⠱⡡⡱⡘⡌⢆⢕⠜⢌⢪⢘⢌⢎⢊⢎⢢⠱⡑⡅⡣⢣⢑⢅⢇⢪⢸⠰⡱⢸⠰⡡⡣⢱⠡⡣⡱⡘⡔⡱⡡⢣⠱⡡⡣⡱⡘⡌
⠪⡊⢆⢣⠱⡨⡢⢣⢑⢢⢃⢇⢕⠱⡨⢢⢃⢎⠢⡣⢱⢘⢌⢆⢣⢊⢆⢣⢡⠣⡪⢪⠸⡐⡕⢅⠇⡕⡌⢎⢌⢆⢣⠱⡑⡱⡨⢢⠣⡱`;
console.log(LOGO);

function togglePhotoElements(){
    Array.from(document.querySelectorAll('.media-group')).forEach(a => {
        if (!a.querySelector('.video')) {
            if (config.showPhotos) {
                $(a.parentElement).css("display", "block");
            } else {
                $(a.parentElement).css("display", "none");
            }
        }
    });
}

function hidePhotoOnlyAlbums() {
    const albumsContainers = document.querySelectorAll('#albums');
    albumsContainers.forEach(a => {
        Array.from(a.children).forEach(a => {
            if (!a.querySelector('.album-videos')) {
                if (config.showPhotoAlbums) {
                    $(a).show();
                } else {
                    $(a).hide();
                }
            }
        });
    });

}

function infiniteScrollAndLazyLoading() {
    // taken from index.html of erome mobile version
    const curPage = window.location.search.match(/page=(\d+)/);
    var next_page = (curPage ? parseInt(curPage) : 1) + 1;

    var infinite = $('#page').infiniteScroll({
        path: function() {
            return location.pathname + '?page=' + next_page;
        },
        append: '.page-content',
        scrollThreshold: 800
    });

    $('#page').on( 'append.infiniteScroll', function( event, body, path, items, response ) {
        hidePhotoOnlyAlbums();
        new LazyLoad();
        next_page = next_page + 1;
        if(next_page > 50  || next_page > 50){
            infinite.destroy();
        }
    });
}

const DEFAULT_CONFIG = {
    showPhotos: false,
    showPhotoAlbums: false
};

const stored = localStorage.getItem("config");
const config = JSON.parse(stored) || DEFAULT_CONFIG;


(function() {
    'use strict';

    if (/^\/a\//.test(window.location.pathname)) {
        togglePhotoElements();
        $('#user_name').parent().append('<button id="togglePhotos" class="btn btn-pink user-hide">show/hide photos</button>');
        $('#togglePhotos').on('click', () => {
            config.showPhotos = !config.showPhotos;
            localStorage.setItem("config", JSON.stringify(config));
            togglePhotoElements();
        });
    } else {
        hidePhotoOnlyAlbums();
        infiniteScrollAndLazyLoading();
        $('.navbar-nav').append('<li><a href="#" id="togglePhotoAlbums">video only</span></a></li>');
        $('#togglePhotoAlbums').css('color', !config.showPhotoAlbums ? '#eb6395' : '#a09f9d');
        $('#togglePhotoAlbums').on('click', () => {
            config.showPhotoAlbums = !config.showPhotoAlbums;
            localStorage.setItem("config", JSON.stringify(config));
            hidePhotoOnlyAlbums();
            $('#togglePhotoAlbums').css('color', !config.showPhotoAlbums ? '#eb6395' : '#a09f9d');
        });
    }
})();