Greasy Fork

Greasy Fork is available in English.

Mangadex - Colorize Reading Status

Change the color of the reading status button depending on the status in title page.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Mangadex - Colorize Reading Status
// @namespace   Violentmonkey Scripts
// @match       https://mangadex.org/title/*
// @grant       none
// @version     1.1
// @author      fa3l 5er
// @description Change the color of the reading status button depending on the status in title page.
// @license MIT
// @noframes
// ==/UserScript==

(function() {
    'use strict';

    // Function to intercept fetch requests and check for 'status'
    const originalFetch = window.fetch;

    window.fetch = async function(input, init) {
        const response = await originalFetch(input, init);

        if (input.includes('status')) {
            // Clone the response to allow multiple reads
            const clonedResponse = response.clone();
            const data = await clonedResponse.json();

            if (data.status) {
                const element = document.querySelector('[data-v-fa81b2e8][data-v-c2249ac3].glow'); // Unreliable query, might need to be changed

                // Change color based on the status
                if (element) {
                    switch (data.status) {
                        case 'reading':
                            element.style.setProperty('--main-color', 'rgb(4 208 0)');
                            break;
                        case 'completed':
                            element.style.setProperty('--main-color', 'rgb(0 201 245)');
                            break;
                        case 'dropped':
                            element.style.setProperty('--main-color', 'rgb(255 64 64)');
                            break;
                        case 'plan_to_read':
                            element.style.setProperty('--main-color', 'GoldenRod');
                            break;
                        case 'on_hold':
                            element.style.setProperty('--main-color', 'rgb(218 117 0)');
                            break;
                        case 're_reading':
                            element.style.setProperty('--main-color', 'rgb(125 64 255)');
                            break;
                    }
                }
            }
        }

        return response; // Return the original response
    };
})();