RosettaCode贡献记录计数器

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

  1. // ==UserScript==
  2. // @name RosettaCode Conribution Records Counter
  3. // @description count specific li elements within section.mw-pager-body
  4. // @name:ar عداد سجلات المساهمات في RosettaCode
  5. // @description:ar عداد عناصر li معينة داخل section.mw-pager-body
  6. // @name:bg Брояч на записи за принос към RosettaCode
  7. // @description:bg Преброява специфични li елементи в section.mw-pager-body
  8. // @name:cs Počítadlo záznamů o příspěvcích RosettaCode
  9. // @description:cs Počítá specifické li elementy uvnitř section.mw-pager-body
  10. // @name:da RosettaCode bidragsrekordtæller
  11. // @description:da Tæller specifikke li-elementer inden for section.mw-pager-body
  12. // @name:de RosettaCode Beitragsdatensatzzähler
  13. // @description:de Zählt bestimmte li-Elemente innerhalb von section.mw-pager-body
  14. // @name:el Μετρητής αρχείων συνεισφοράς RosettaCode
  15. // @description:el Μετράει συγκεκριμένα στοιχεία li μέσα στο section.mw-pager-body
  16. // @name:eo RosettaCode Kontribuaĵo-Rekordoj-Nombrilo
  17. // @description:eo Kalkulas specifajn li elementojn ene de section.mw-pager-body
  18. // @name:es Contador de registros de contribuciones de RosettaCode
  19. // @description:es Cuenta elementos li específicos dentro de section.mw-pager-body
  20. // @name:fi RosettaCode Osallistumistietojen laskuri
  21. // @description:fi Laskee tietyt li-elementit section.mw-pager-body -sisällä
  22. // @name:fr Compteur d'enregistrements de contributions RosettaCode
  23. // @description:fr Compte les éléments li spécifiques dans section.mw-pager-body
  24. // @name:fr-CA Compteur d'enregistrements de contributions RosettaCode
  25. // @description:fr-CA Compte les éléments li spécifiques dans section.mw-pager-body
  26. // @name:he מונה רשומות תרומה של RosettaCode
  27. // @description:he סופר רכיבי li ספציפיים בתוך section.mw-pager-body
  28. // @name:hr Brojač zapisa doprinosa za RosettaCode
  29. // @description:hr Broji određene li elemente unutar section.mw-pager-body
  30. // @name:hu RosettaCode Hozzájárulás-rekord számláló
  31. // @description:hu Megszámolja a specifikus li elemeket a section.mw-pager-body-n belül
  32. // @name:id Penghitung Catatan Kontribusi RosettaCode
  33. // @description:id Menghitung elemen li tertentu di dalam section.mw-pager-body
  34. // @name:it Contatore di record di contributo di RosettaCode
  35. // @description:it Conta elementi li specifici all'interno di section.mw-pager-body
  36. // @name:ja RosettaCode投稿記録カウンター
  37. // @description:ja section.mw-pager-body内の特定のli要素をカウントします
  38. // @name:ka RosettaCode-ის წვლილის ჩანაწერების მთვლელი
  39. // @description:ka ითვლის კონკრეტულ li ელემენტებს section.mw-pager-body-ში
  40. // @name:ko RosettaCode 기여 기록 카운터
  41. // @description:ko section.mw-pager-body 내의 특정 li 요소를 계산합니다.
  42. // @name:nb RosettaCode bidragsrekordteller
  43. // @description:nb Teller spesifikke li-elementer innenfor section.mw-pager-body
  44. // @name:nl RosettaCode Bijdrage Records Teller
  45. // @description:nl Telt specifieke li-elementen binnen section.mw-pager-body
  46. // @name:pl Licznik rekordów kontrybucji RosettaCode
  47. // @description:pl Zlicza określone elementy li wewnątrz section.mw-pager-body
  48. // @name:pt-BR Contador de Registros de Contribuições do RosettaCode
  49. // @description:pt-BR Conta elementos li específicos dentro de section.mw-pager-body
  50. // @name:ro Contor de înregistrări de contribuții RosettaCode
  51. // @description:ro Numără elemente li specifice în interiorul section.mw-pager-body
  52. // @name:ru Счетчик записей о вкладе в RosettaCode
  53. // @description:ru Подсчитывает определенные элементы li внутри section.mw-pager-body
  54. // @name:sk Počítadlo záznamov o príspevkoch RosettaCode
  55. // @description:sk Počíta špecifické li elementy vnútri section.mw-pager-body
  56. // @name:sr Бројач записа о доприносима за RosettaCode
  57. // @description:sr Броји одређене li елементе унутар section.mw-pager-body
  58. // @name:sv RosettaCode bidragsregisterräknare
  59. // @description:sv Räknar specifika li-element inom section.mw-pager-body
  60. // @name:th ตัวนับบันทึกการมีส่วนร่วมของ RosettaCode
  61. // @description:th นับองค์ประกอบ li เฉพาะภายใน section.mw-pager-body
  62. // @name:tr RosettaCode Katkı Kayıtları Sayacı
  63. // @description:tr section.mw-pager-body içindeki belirli li öğelerini sayar
  64. // @name:ug RosettaCode تۆھپە خاتىرىسى سانىغۇچ
  65. // @description:ug section.mw-pager-body ئىچىدىكى كونكرېت li ئېلېمېنتلىرىنى ھېسابلايدۇ
  66. // @name:uk Лічильник записів внеску RosettaCode
  67. // @description:uk Підраховує певні елементи li всередині section.mw-pager-body
  68. // @name:vi Bộ đếm hồ sơ đóng góp RosettaCode
  69. // @description:vi Đếm các phần tử li cụ thể bên trong section.mw-pager-body
  70. // @name:zh RosettaCode贡献记录计数器
  71. // @description:zh 计算 section.mw-pager-body 中特定的 li 元素
  72. // @name:zh-CN RosettaCode贡献记录计数器
  73. // @description:zh-CN 计算 section.mw-pager-body 中特定的 li 元素
  74. // @name:zh-HK RosettaCode貢獻記錄計數器
  75. // @description:zh-HK 計算 section.mw-pager-body 中特定的 li 元素
  76. // @name:zh-SG RosettaCode贡献记录计数器
  77. // @description:zh-SG 计算 section.mw-pager-body 中特定的 li 元素
  78. // @name:zh-TW RosettaCode貢獻記錄計數器
  79. // @description:zh-TW 計算 section.mw-pager-body 中特定的 li 元素
  80. // @namespace http://tampermonkey.net/
  81. // @version 1.0.2.2
  82. // @author aspen138
  83. // @match *://rosettacode.org/wiki/Special:Contributions?end=&limit=5000&namespace=all&start=&tagfilter=&target=*
  84. // @match *://rosettacode.org/wiki/Special:Contributions*
  85. // @match *://rosettacode.miraheze.org/wiki/Special:Contributions?end=&limit=5000&namespace=all&start=&tagfilter=&target=*
  86. // @match *://rosettacode.miraheze.org/wiki/Special:Contributions*
  87. // @grant none
  88. // @license MIT
  89. // ==/UserScript==
  90.  
  91.  
  92. (function() {
  93. 'use strict';
  94.  
  95. function countAndDisplayDistinctTitles() {
  96. // Find the target section
  97. var section = document.querySelector('section.mw-pager-body');
  98. if (!section) return;
  99.  
  100. // Collect all title attributes from 'a' elements
  101. var liElements = section.querySelectorAll('a.mw-contributions-title');
  102. var titlesSet = new Set();
  103. liElements.forEach(function(aElement) {
  104. var title = aElement.getAttribute('title');
  105. if (title && !title.startsWith('User:') && !title.startsWith('File:')) {
  106. titlesSet.add(title);
  107. }
  108. });
  109. console.log('titlesSet=',titlesSet);
  110.  
  111. // Count distinct titles
  112. var countDistinctTitles = titlesSet.size;
  113.  
  114. // Create a new element to display the count of distinct titles
  115. var resultDisplay = document.createElement('div');
  116. resultDisplay.textContent = `(RosettaCode Contribution Records Counter) Count of distinct titles: ${countDistinctTitles}`;
  117. resultDisplay.style.backgroundColor = 'yellow'; // Set the background color to yellow
  118. resultDisplay.style.color = 'blue'; // Optional: Set text color to blue for better readability
  119. resultDisplay.style.padding = '10px'; // Optional: Add some padding
  120. resultDisplay.style.marginBottom = '10px'; // Optional: Add some margin at the bottom
  121. resultDisplay.style.border = "2px solid black";
  122.  
  123. // Insert the results as the first child of the section
  124. if (section.firstChild) {
  125. section.insertBefore(resultDisplay, section.firstChild);
  126. } else {
  127. section.appendChild(resultDisplay);
  128. }
  129. }
  130.  
  131. // Assuming this function is called when the document is fully loaded
  132. window.addEventListener('load', countAndDisplayDistinctTitles);
  133. })();
  134.  

QingJ © 2025

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