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 เพื่อติดตั้งสคริปต์นี้

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

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