jpdb.io - show non-redundant vocab on learn page

Replaces the "You know" known words stat with the "Total known non-redundant vocabulary" value

2025-09-16 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         jpdb.io - show non-redundant vocab on learn page
// @namespace    http://tampermonkey.net/
// @description  Replaces the "You know" known words stat with the "Total known non-redundant vocabulary" value
// @version      1.0
// @author       JawGBoi
// @match        https://jpdb.io/learn*
// @grant        none
// @run-at       document-idle
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    const totalWords = document.querySelector('table.cross-table tr:nth-child(2) td:nth-child(2)');
    const knownWords = document.querySelector('table.cross-table tr:nth-child(2) td:last-child');
    const nonRedundantSection = document.querySelector('table.cross-table + p');

    // script can only run if required elements are found
    if (nonRedundantSection && totalWords && knownWords) {
        try {
            // find the number at the end of the paragraph's text:
            const nonRedundantText = nonRedundantSection.textContent;
            const nonRedundantMatch = nonRedundantText.match(/(\d+)$/);
            const nonRedundantCount = parseInt(nonRedundantMatch[1], 10);

            // get total word count
            const totalNoWord = parseInt(totalWords.textContent.replace(/,/g, ''), 10);

            nonRedundantSection.remove(); // no need for the redundant words section anymore

            // recalculate percentage:
            let newPercentage = 0;
            if (totalNoWord > 0) {
                newPercentage = Math.floor((nonRedundantCount / totalNoWord) * 100);
            }

            // 5. Format the new string and update the 'You know' cell.
            knownWords.textContent = `${nonRedundantCount} (${newPercentage}%)`;

        }
        catch (error)
        {
            console.error("jpdb non redundant vocab script error:", error);
        }
    }
}
)();