DBLP Page Count Display

Add total page count to DBLP paper listings

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         DBLP Page Count Display
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Add total page count to DBLP paper listings
// @author       You
// @match        https://dblp.org/*
// @match        https://dblp.uni-trier.de/*
// @match        https://*.dblp.org/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function addPageCounts() {
        // Find all pagination spans
        const paginationSpans = document.querySelectorAll('span[itemprop="pagination"]');

        paginationSpans.forEach(span => {
            // Check if we've already processed this span
            if (span.dataset.processed) return;

            const pageRange = span.textContent.trim();

            // Match patterns like "23-42" or "123-456"
            const match = pageRange.match(/^(\d+)-(\d+)$/);

            if (match) {
                const startPage = parseInt(match[1], 10);
                const endPage = parseInt(match[2], 10);
                const totalPages = endPage - startPage + 1;

                // Create a new span for the page count
                const countSpan = document.createElement('span');
                countSpan.textContent = ` (${totalPages} pages)`;
                countSpan.style.color = '#666';
                countSpan.style.fontSize = '0.95em';

                // Insert after the pagination span
                span.parentNode.insertBefore(countSpan, span.nextSibling);

                // Mark as processed
                span.dataset.processed = 'true';
            }
        });
    }

    // Run initially
    addPageCounts();

    // Watch for dynamic content changes
    const observer = new MutationObserver(() => {
        addPageCounts();
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
})();