DBLP Page Count Display

Add total page count to DBLP paper listings

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==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
    });
})();