PocketBook - Grayscale Online Reader

Set grayscale effect to the actual page to avoid wrong colors in some pages in PDF reading.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @icon            https://cloud.pocketbook.digital/reader_new/static/media/logo.74f9be12.svg
// @name            PocketBook - Grayscale Online Reader
// @version         1.0
// @author          R4wwd0G
// @description     Set grayscale effect to the actual page to avoid wrong colors in some pages in PDF reading.
// @include			https://cloud.pocketbook.digital/reader_new/*
// @namespace https://greasyfork.org/users/700468
// ==/UserScript==



function applyGrayscale() {
    document.querySelectorAll('.page-img').forEach(img => {
        img.style.filter = 'grayscale(1)';
    });
}


applyGrayscale();


const observer = new MutationObserver(mutations => {
    mutations.forEach(mutation => {
        if (mutation.type === 'childList') {
            mutation.addedNodes.forEach(node => {
                if (node.classList && node.classList.contains('page-img')) {
                    node.style.filter = 'grayscale(1)';
                }
            });
        }
    });
});


observer.observe(document.querySelector('#Reader__content'), { childList: true, subtree: true });