8muses Improved

Improvements to 8muses: on images pages, move breadcrumb to sidebar and hide header

Stan na 14-01-2021. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         8muses Improved
// @namespace    Hentiedup
// @version      0.1.3
// @description  Improvements to 8muses: on images pages, move breadcrumb to sidebar and hide header
// @author       Hentiedup
// @match        https://comics.8muses.com/*
// @grant        none
// @noframes
// ==/UserScript==

(function() {
    'use strict';

    //========================= OPTIONS =========================//
           var moveBreadcrumbsAndHideHeaderOnImages = true;
           var hideTitleAttributeFromImages         = true;
           var hideEmptyOrAdSectionsFromSidebar     = true;
           var fixSomeObviousProblems               = true;
    //===========================================================//

    if(hideEmptyOrAdSectionsFromSidebar)
    {
        let targets = document.querySelectorAll(".menu-items > .ui-menu-item > a[rel=noopener]");
        for(let i = 0; i < targets.length; i++)
        {
            targets[i].parentNode.style.display = "none";
        }
    }

    if(fixSomeObviousProblems)
    {
        addGlobalStyle(`
           html, body, #ractive-body, #b-wrapper { min-height: 100vh !important; }
        `);
    }

    if(window.location.href.includes("/comics/picture/"))
    {
        if(hideTitleAttributeFromImages)
        {
            document.querySelector(".photo > a").setAttribute("title", "");
            let target = document.querySelector(".photo > meta");
            let observer = new MutationObserver(() => {
                document.querySelector(".photo > a").setAttribute("title", "");
            });
            observer.observe(target, {attributes: true});
        }

        if(moveBreadcrumbsAndHideHeaderOnImages)
        {
            addGlobalStyle(`
               #top-menu, #left-menu-close { display: none; }
               #left-menu, #left-menu.force-open, #b-wrapper { padding-top: 0; }
               #newBreadcrumb li { line-height: 1.2em; padding: 0 10px; }
               #newBreadcrumb ol { list-style: none; padding: 10px 0; }
               #content[style*="display: inline-block;"] .photo img { max-height: calc(100vh) !important; }
            `);

            var breadcrumb = document.querySelector(".top-menu-breadcrumb").cloneNode(true);
            breadcrumb.setAttribute("id", "newBreadcrumb");
            document.querySelector(".menu-items > .menu-logo").className = "";

            let beforeTarget = document.querySelector(".page-select");
            beforeTarget.parentNode.insertBefore(breadcrumb, beforeTarget);

            var lis = document.getElementById("newBreadcrumb").getElementsByTagName("li");
            for(let i = 0; i < lis.length; i++)
            {
                if(i != 0)
                    lis[i].insertBefore(document.createTextNode("⤷ "), lis[i].firstChild);
            }
        }
    }

    function addGlobalStyle(css) {
        var head, style;
        head = document.getElementsByTagName('head')[0];
        if (!head) { return; }
        style = document.createElement('style');
        style.type = 'text/css';
        style.innerHTML = css;
        head.appendChild(style);
    }
})();