Erome.com Improved

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

ของเมื่อวันที่ 19-04-2024 ดู เวอร์ชันล่าสุด

// ==UserScript==
// @name         Erome.com Improved
// @namespace    http://tampermonkey.net/
// @version      1.0.2
// @license      MIT
// @description  Infinite scroll. Filter photo albums. Show/hide photos in albums.
// @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) + 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();
    console.log({next_page});

        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');
        });
    }
})();