Kutubee Reading Script

Intercepts the final reading completion request and sets the 'duration' to a high value (312 seconds) to bypass server-side time checks.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Kutubee Reading Script
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Intercepts the final reading completion request and sets the 'duration' to a high value (312 seconds) to bypass server-side time checks.
// @author       neonmodder123
// @match        https://read.kutubee.com/*
// @grant        none
// @run-at       document-start
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    console.log("Kutubee Script Working :)");
    const TARGET_DURATION = 312;
    const TARGET_API_PATH = '/api/user-activity';
    const originalFetch = window.fetch;

    window.fetch = async function(resource, options) {

        const url = resource.toString();
        const method = options?.method;
        const isPostOrPut = options && (method === 'POST' || method === 'PUT');

        const isTargetApi = url.includes(TARGET_API_PATH);

        if (isTargetApi && isPostOrPut && options.body) {

            let originalPayload;

            try {
                originalPayload = JSON.parse(options.body);
                if (originalPayload.tryingToComplete === true && originalPayload.activitySessionInfo) {

                    const sessionInfo = originalPayload.activitySessionInfo;

                    console.log(`[Kutubee Script] INTERCEPTED completion attempt for ${originalPayload.contentId}`);
                    console.log(`[Kutubee Script] Original Duration: ${sessionInfo.duration}s`);

                    sessionInfo.duration = TARGET_DURATION;

                    options.body = JSON.stringify(originalPayload);

                    console.log(`[Kutubee Script] New Duration Injected: ${sessionInfo.duration}s`);
                    console.log("[Kutubee Script] Sending modified request to server...");
                }
            } catch (e) {
                console.error("[Kutubee Script] Error during payload modification, request sent unedited:", e);
            }
        }
        return originalFetch(resource, options);
    };

})();