RosettaCode Conribution Records Counter

count specific li elements within section.mw-pager-body

Stan na 12-02-2024. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         RosettaCode Conribution Records Counter
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  count specific li elements within section.mw-pager-body
// @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 to count and insert result
    function countAndDisplayLiElements() {
        // Find the target section
        var section = document.querySelector('section.mw-pager-body');
        if (!section) return;

        // Count li elements that match the criteria
        var liElements = section.querySelectorAll('li.mw-contributions-current.mw-tag-wikieditor');
        var count = liElements.length;

        // Create a new element to display the count
        var resultDisplay = document.createElement('div');
        resultDisplay.textContent = `(IN THIS PAGE) Count of matching Conribution Records: ${count}`;
        resultDisplay.style.backgroundColor = 'yellow'; // Set the background color to blue
        resultDisplay.style.color = 'blue'; // Optional: Set text color to white 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 result as the first child of the section
        if (section.firstChild) {
            section.insertBefore(resultDisplay, section.firstChild);
        } else {
            section.appendChild(resultDisplay);
        }
    }

    // Run the function when the page loads
    window.addEventListener('load', countAndDisplayLiElements);
})();