F95 Redesign

F95Zone Redesign

// ==UserScript==
// @name         F95 Redesign
// @namespace    https://github.com/wandersons13/F95-Redesign
// @version      0.4
// @description  F95Zone Redesign
// @author       wandersons13
// @match        https://f95zone.to/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=f95zone.to
// @license      GNU
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const windowWidth = window.innerWidth;
    const selectorsToHide = [
        '.p-sectionLinks',
        '.uix_extendedFooter',
        '.p-footer-inner',
        '.view-thread.block--similarContents.block-container',
        '.js-notices.notices--block.notices'
    ];

    const addCustomStyles = () => {
        const style = document.createElement('style');
        style.id = 'custom-styles';
        style.innerHTML = `
            .pageContent {
                max-width: ${windowWidth * 0.95}px !important;
                max-height: 360px !important;
                transition: none !important;
                top: 110px !important;
            }
            .p-body-inner, .p-nav-inner {
                max-width: ${windowWidth * 0.95}px !important;
                transition: none !important;
            }
            .cover-hasImage {
                height: 360px !important;
                transition: none !important;
            }
            @media screen and (min-width: 1369px) {
                div#latest-page_items-wrap_inner.resource-wrap-game.grid-normal {
                    grid-template-columns: repeat(5, 25%) !important;
                }
                div#latest-page_items-wrap {
                    margin-left: -312px !important;
                }
                #latest-page_filter-wrap {
                    margin-right: -312px !important;
                }
            }
            @media screen and (min-width: 1301px) and (max-width: 1366px) {
                div#latest-page_items-wrap_inner.resource-wrap-game.grid-normal {
                    grid-template-columns: repeat(4, 20%) !important;
                }
                div#latest-page_items-wrap {
                    margin-left: -45px !important;
                }
                #latest-page_filter-wrap {
                    margin-left: -155px !important;
                }
            }
        `;
        document.head.appendChild(style);
    };

    const highlightUnreadLinks = () => {
        document.querySelectorAll('a').forEach(link => {
            const buttonText = link.querySelector('.button-text');
            if (link.href.includes('/unread?new=1') || (buttonText && buttonText.textContent.trim().toLowerCase() === 'jump to new')) {
                if (buttonText) {
                    buttonText.classList.add('highlight-unread');
                }
            }
        });
    };

    const applyUblockFilters = () => {
        selectorsToHide.forEach(selector => {
            document.querySelectorAll(selector).forEach(el => el.style.display = 'none');
        });
    };

    const init = () => {
        addCustomStyles();
        highlightUnreadLinks();
        applyUblockFilters();
    };

    const style = document.createElement('style');
    style.innerHTML = `
        .highlight-unread {
            color: cyan;
            font-weight: bold;
            text-shadow: 1px 1px 2px black;
        }
    `;
    document.head.appendChild(style);

    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', init, { once: true });
    } else {
        init();
    }
})();