RosettaCode貢獻記錄計數器

計算 section.mw-pager-body 中特定的 li 元素

// ==UserScript==
// @name         RosettaCode Conribution Records Counter
// @description  count specific li elements within section.mw-pager-body
// @name:ar          عداد سجلات المساهمات في RosettaCode
// @description:ar    عداد عناصر li معينة داخل section.mw-pager-body
// @name:bg          Брояч на записи за принос към RosettaCode
// @description:bg    Преброява специфични li елементи в section.mw-pager-body
// @name:cs          Počítadlo záznamů o příspěvcích RosettaCode
// @description:cs    Počítá specifické li elementy uvnitř section.mw-pager-body
// @name:da          RosettaCode bidragsrekordtæller
// @description:da    Tæller specifikke li-elementer inden for section.mw-pager-body
// @name:de          RosettaCode Beitragsdatensatzzähler
// @description:de    Zählt bestimmte li-Elemente innerhalb von section.mw-pager-body
// @name:el          Μετρητής αρχείων συνεισφοράς RosettaCode
// @description:el    Μετράει συγκεκριμένα στοιχεία li μέσα στο section.mw-pager-body
// @name:eo          RosettaCode Kontribuaĵo-Rekordoj-Nombrilo
// @description:eo    Kalkulas specifajn li elementojn ene de section.mw-pager-body
// @name:es          Contador de registros de contribuciones de RosettaCode
// @description:es    Cuenta elementos li específicos dentro de section.mw-pager-body
// @name:fi          RosettaCode Osallistumistietojen laskuri
// @description:fi    Laskee tietyt li-elementit section.mw-pager-body -sisällä
// @name:fr          Compteur d'enregistrements de contributions RosettaCode
// @description:fr    Compte les éléments li spécifiques dans section.mw-pager-body
// @name:fr-CA       Compteur d'enregistrements de contributions RosettaCode
// @description:fr-CA    Compte les éléments li spécifiques dans section.mw-pager-body
// @name:he          מונה רשומות תרומה של RosettaCode
// @description:he    סופר רכיבי li ספציפיים בתוך section.mw-pager-body
// @name:hr          Brojač zapisa doprinosa za RosettaCode
// @description:hr    Broji određene li elemente unutar section.mw-pager-body
// @name:hu          RosettaCode Hozzájárulás-rekord számláló
// @description:hu    Megszámolja a specifikus li elemeket a section.mw-pager-body-n belül
// @name:id          Penghitung Catatan Kontribusi RosettaCode
// @description:id    Menghitung elemen li tertentu di dalam section.mw-pager-body
// @name:it          Contatore di record di contributo di RosettaCode
// @description:it    Conta elementi li specifici all'interno di section.mw-pager-body
// @name:ja          RosettaCode投稿記録カウンター
// @description:ja    section.mw-pager-body内の特定のli要素をカウントします
// @name:ka          RosettaCode-ის წვლილის ჩანაწერების მთვლელი
// @description:ka    ითვლის კონკრეტულ li ელემენტებს section.mw-pager-body-ში
// @name:ko          RosettaCode 기여 기록 카운터
// @description:ko    section.mw-pager-body 내의 특정 li 요소를 계산합니다.
// @name:nb          RosettaCode bidragsrekordteller
// @description:nb    Teller spesifikke li-elementer innenfor section.mw-pager-body
// @name:nl          RosettaCode Bijdrage Records Teller
// @description:nl    Telt specifieke li-elementen binnen section.mw-pager-body
// @name:pl          Licznik rekordów kontrybucji RosettaCode
// @description:pl    Zlicza określone elementy li wewnątrz section.mw-pager-body
// @name:pt-BR       Contador de Registros de Contribuições do RosettaCode
// @description:pt-BR    Conta elementos li específicos dentro de section.mw-pager-body
// @name:ro          Contor de înregistrări de contribuții RosettaCode
// @description:ro    Numără elemente li specifice în interiorul section.mw-pager-body
// @name:ru          Счетчик записей о вкладе в RosettaCode
// @description:ru    Подсчитывает определенные элементы li внутри section.mw-pager-body
// @name:sk          Počítadlo záznamov o príspevkoch RosettaCode
// @description:sk    Počíta špecifické li elementy vnútri section.mw-pager-body
// @name:sr          Бројач записа о доприносима за RosettaCode
// @description:sr    Броји одређене li елементе унутар section.mw-pager-body
// @name:sv          RosettaCode bidragsregisterräknare
// @description:sv    Räknar specifika li-element inom section.mw-pager-body
// @name:th          ตัวนับบันทึกการมีส่วนร่วมของ RosettaCode
// @description:th    นับองค์ประกอบ li เฉพาะภายใน section.mw-pager-body
// @name:tr          RosettaCode Katkı Kayıtları Sayacı
// @description:tr    section.mw-pager-body içindeki belirli li öğelerini sayar
// @name:ug          RosettaCode تۆھپە خاتىرىسى سانىغۇچ
// @description:ug    section.mw-pager-body ئىچىدىكى كونكرېت li ئېلېمېنتلىرىنى ھېسابلايدۇ
// @name:uk          Лічильник записів внеску RosettaCode
// @description:uk    Підраховує певні елементи li всередині section.mw-pager-body
// @name:vi          Bộ đếm hồ sơ đóng góp RosettaCode
// @description:vi    Đếm các phần tử li cụ thể bên trong section.mw-pager-body
// @name:zh          RosettaCode贡献记录计数器
// @description:zh    计算 section.mw-pager-body 中特定的 li 元素
// @name:zh-CN       RosettaCode贡献记录计数器
// @description:zh-CN    计算 section.mw-pager-body 中特定的 li 元素
// @name:zh-HK       RosettaCode貢獻記錄計數器
// @description:zh-HK    計算 section.mw-pager-body 中特定的 li 元素
// @name:zh-SG       RosettaCode贡献记录计数器
// @description:zh-SG    计算 section.mw-pager-body 中特定的 li 元素
// @name:zh-TW       RosettaCode貢獻記錄計數器
// @description:zh-TW    計算 section.mw-pager-body 中特定的 li 元素
// @namespace    http://tampermonkey.net/
// @version      1.0.2.1
// @author       aspen138
// @match        *://rosettacode.org/wiki/Special:Contributions?end=&limit=5000&namespace=all&start=&tagfilter=&target=*
// @match        *://rosettacode.org/wiki/Special:Contributions*
// @grant        none
// @license    MIT
// ==/UserScript==


(function() {
    'use strict';

    function countAndDisplayDistinctTitles() {
        // Find the target section
        var section = document.querySelector('section.mw-pager-body');
        if (!section) return;

        // Collect all title attributes from 'a' elements
        var liElements = section.querySelectorAll('a.mw-contributions-title');
        var titlesSet = new Set();
        liElements.forEach(function(aElement) {
            var title = aElement.getAttribute('title');
            if (title && !title.startsWith('User:') && !title.startsWith('File:')) {
                titlesSet.add(title);
            }
        });
        console.log('titlesSet=',titlesSet);

        // Count distinct titles
        var countDistinctTitles = titlesSet.size;

        // Create a new element to display the count of distinct titles
        var resultDisplay = document.createElement('div');
        resultDisplay.textContent = `(RosettaCode Contribution Records Counter) Count of distinct titles: ${countDistinctTitles}`;
        resultDisplay.style.backgroundColor = 'yellow'; // Set the background color to yellow
        resultDisplay.style.color = 'blue'; // Optional: Set text color to blue for better readability
        resultDisplay.style.padding = '10px'; // Optional: Add some padding
        resultDisplay.style.marginBottom = '10px'; // Optional: Add some margin at the bottom
        resultDisplay.style.border = "2px solid black";

        // Insert the results as the first child of the section
        if (section.firstChild) {
            section.insertBefore(resultDisplay, section.firstChild);
        } else {
            section.appendChild(resultDisplay);
        }
    }

    // Assuming this function is called when the document is fully loaded
    window.addEventListener('load', countAndDisplayDistinctTitles);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址