您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Likes Counter
// ==UserScript== // @name Likes Counter by_el9in // @namespace Likes Counter by_el9in // @version 0.3 // @description Likes Counter // @author You // @match https://zelenka.guru/forums/contests/* // @icon https://www.google.com/s2/favicons?sz=64&domain=zelenka.guru // @grant none // @license el9in // ==/UserScript== (function() { 'use strict'; const max = 5; function calculateAverage(numbers) { if (!Array.isArray(numbers) || numbers.length === 0) { // Проверяем, является ли numbers массивом и не пуст ли он return null; } const sum = numbers.reduce((accumulator, currentValue) => accumulator + currentValue, 0); const average = sum / numbers.length; return average; } const originalFastButton = document.querySelector('a.button.middle.CreatePersonalExtendedTab'); if (originalFastButton) { const clonedButton = originalFastButton.cloneNode(true); clonedButton.classList.remove('CreatePersonalExtendedTab'); clonedButton.classList.add('SrLikes'); clonedButton.textContent = 'Fast'; clonedButton.style.marginLeft = '5px'; clonedButton.removeAttribute('href'); originalFastButton.parentNode.insertBefore(clonedButton, originalFastButton.nextSibling); clonedButton.addEventListener('click', function(event) { initLikes(); }); let buttonIn = false; async function initLikes() { if(buttonIn == true) { clonedButton.textContent = 'Жди! Ещё идёт подчёт.'; return; } else clonedButton.textContent = `Идёт подсчёт (${0}/${max})`; buttonIn = true; if(window.location.href != "https://zelenka.guru/forums/contests/?node_id=766&order=post_date&direction=desc") { window.location.href = 'https://zelenka.guru/forums/contests/?node_id=766&order=post_date&direction=desc'; return; } const threads = document.querySelector(".latestThreads._insertLoadedContent"); const threadsHrefs = threads.querySelectorAll(".listBlock.main.PreviewTooltip"); const threadsHrefsFast = []; for(let thread of threadsHrefs) { const isFast = thread.querySelector(".prefix.icon.fast_contest"); if(isFast) threadsHrefsFast.push(thread); } const LikesObject = []; let i = 0; for(let thread of threadsHrefsFast) { if(i >= max) break; const response = await fetch(thread.href); console.log(thread.href); const html = await response.text(); const parser = new DOMParser(); const doc = parser.parseFromString(html, 'text/html'); await new Promise(resolve => setTimeout(resolve, 2000)); const Likes = doc.querySelector('span.LikeLabel'); const LikesCount = Likes.innerText | 0; LikesObject.push(LikesCount); i++; clonedButton.textContent = `Идёт подсчёт (${i}/${max})`; } buttonIn = false; clonedButton.textContent = `Fast (${Math.round( calculateAverage(LikesObject) )})`; } } const originalButton = document.querySelector('a.button.middle.CreatePersonalExtendedTab'); if (originalButton) { const clonedButton = originalButton.cloneNode(true); clonedButton.classList.remove('CreatePersonalExtendedTab'); clonedButton.classList.add('SrLikes'); clonedButton.textContent = 'Количество лайков'; clonedButton.style.marginLeft = '5px'; clonedButton.removeAttribute('href'); originalButton.parentNode.insertBefore(clonedButton, originalButton.nextSibling); clonedButton.addEventListener('click', function(event) { initLikes(); }); let buttonIn = false; async function initLikes() { if(buttonIn == true) { clonedButton.textContent = 'Жди! Ещё идёт подчёт.'; return; } else clonedButton.textContent = `Идёт подсчёт (${0}/${max})`; buttonIn = true; if(window.location.href != "https://zelenka.guru/forums/contests/?node_id=766&order=post_date&direction=desc") { window.location.href = 'https://zelenka.guru/forums/contests/?node_id=766&order=post_date&direction=desc'; return; } const threads = document.querySelector(".latestThreads._insertLoadedContent"); const threadsHrefs = threads.querySelectorAll(".listBlock.main.PreviewTooltip"); const LikesObject = []; let i = 0; for(let thread of threadsHrefs) { if(i >= max) break; const response = await fetch(thread.href); console.log(thread.href); const html = await response.text(); const parser = new DOMParser(); const doc = parser.parseFromString(html, 'text/html'); await new Promise(resolve => setTimeout(resolve, 2000)); const Likes = doc.querySelector('span.LikeLabel'); const LikesCount = Likes.innerText | 0; LikesObject.push(LikesCount); i++; clonedButton.textContent = `Идёт подсчёт (${i}/${max})`; } buttonIn = false; clonedButton.textContent = `Количество лайков (${Math.round( calculateAverage(LikesObject) )})`; } } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址