// ==UserScript== // @name GreasyFork用户主页显示该用户所有脚本的今日总安装次数和迄今总安装次数 // @namespace http://tampermonkey.net/ // @version 0.2 // @description 在GreasyFork用户主页显示该用户所有脚本的今日总安装次数和迄今总安装次数。 // @author aspen138 // @match https://greasyfork.org/*/users/* // @grant none // @license MIT // @locale en The GreasyFork user homepage displays the total number of installations of all scripts for the user today and the total number of installations to date. // @locale zh-CN GreasyFork用户主页显示该用户所有脚本的今日总安装次数和迄今总安装次数。 // @locale zh-TW GreasyFork用戶主頁顯示該用戶所有腳本的今日總安裝次數和迄今總安裝次數。 // @locale ja GreasyForkユーザーホームページには、その日のユーザーのすべてのスクリプトの合計インストール回数と、これまでの総インストール回数が表示されます。 // @locale ko GreasyFork 사용자 홈페이지는 해당 사용자의 모든 스크립트에 대한 당일 총 설치 횟수와 지금까지의 총 설치 횟수를 표시합니다。 // @downloadURL none // ==/UserScript== (function() { 'use strict'; const sumInstalls = (selector) => Array.from(document.querySelectorAll(selector)) .reduce((sum, el) => sum + (parseInt(el.textContent, 10) || 0), 0); const displayTotals = (daily, total) => { const userHeader = document.querySelector('#about-user h2'); const language = document.documentElement.lang; // Get the current language of the document let dailyInstallsText = ''; let totalInstallsText = ''; // Determine the text based on the current language switch (language) { case 'en': dailyInstallsText = `Total daily installations for all scripts: ${daily}`; totalInstallsText = `Total installations to date for all scripts: ${total}`; break; case 'zh-CN': dailyInstallsText = `该用户所有脚本的今日总安装次数:${daily}`; totalInstallsText = `该用户所有脚本的迄今总安装次数:${total}`; break; case 'zh-TW': dailyInstallsText = `該用戶所有腳本的今日總安裝次數:${daily}`; totalInstallsText = `該用戶所有腳本的迄今總安裝次數:${total}`; break; case 'ja': dailyInstallsText = `本日の全スクリプトの合計インストール回数:${daily}`; totalInstallsText = `全スクリプトの累計インストール回数:${total}`; break; case 'ko': dailyInstallsText = `해당 사용자의 모든 스크립트에 대한 오늘의 총 설치 횟수: ${daily}`; totalInstallsText = `해당 사용자의 모든 스크립트에 대한 총 설치 횟수: ${total}`; break; // ... add other languages if needed default: dailyInstallsText = `Total daily installations for all scripts: ${daily}`; totalInstallsText = `Total installations to date for all scripts: ${total}`; } if (userHeader) { userHeader.insertAdjacentHTML('afterend', `
${dailyInstallsText}
${totalInstallsText}
`); } }; const dailyInstallsSum = sumInstalls('dd.script-list-daily-installs > span'); const totalInstallsSum = sumInstalls('dd.script-list-total-installs > span'); displayTotals(dailyInstallsSum, totalInstallsSum); })();