// ==UserScript== // @name GreasyFork用户主页显示该用户发布脚本数目、所有脚本的今日总安装次数和迄今总安装次数 // @namespace http://tampermonkey.net/ // @version 0.2.4 // @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== var publishedScriptsNumber = -1; (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': publishedScriptsNumber = `Number of published scripts: ${publishedScriptsNumber}`; dailyInstallsText = `Total daily installations for all scripts: ${daily}`; totalInstallsText = `Total installations to date for all scripts: ${total}`; break; case 'zh-CN': publishedScriptsNumber = `已发布脚本总数:${publishedScriptsNumber}`; dailyInstallsText = `该用户所有脚本的今日总安装次数:${daily}`; totalInstallsText = `该用户所有脚本的迄今总安装次数:${total}`; break; case 'zh-TW': publishedScriptsNumber = `已發布腳本總數:${publishedScriptsNumber}`; dailyInstallsText = `該用戶所有腳本的今日總安裝次數:${daily}`; totalInstallsText = `該用戶所有腳本的迄今總安裝次數:${total}`; break; case 'ja': publishedScriptsNumber = `公開されたスクリプトの合計:${publishedScriptsNumber}`; dailyInstallsText = `本日の全スクリプトの合計インストール回数:${daily}`; totalInstallsText = `全スクリプトの累計インストール回数:${total}`; break; case 'ko': publishedScriptsNumber = `게시된 스크립트 총 수: ${publishedScriptsNumber}`; dailyInstallsText = `해당 사용자의 모든 스크립트에 대한 오늘의 총 설치 횟수: ${daily}`; totalInstallsText = `해당 사용자의 모든 스크립트에 대한 총 설치 횟수: ${total}`; break; // ... add other languages if needed default: publishedScriptsNumber = `Number of published scripts: ${publishedScriptsNumber}`; dailyInstallsText = `Total daily installations for all scripts: ${daily}`; totalInstallsText = `Total installations to date for all scripts: ${total}`; } if (userHeader) { userHeader.insertAdjacentHTML('afterend', ` ${publishedScriptsNumber}
${dailyInstallsText}
${totalInstallsText}
`); } }; const dailyInstallsSum = sumInstalls('dd.script-list-daily-installs > span'); const totalInstallsSum = sumInstalls('dd.script-list-total-installs > span'); (function() { var list = document.querySelector('ol#user-script-list.script-list.showing-all-languages'); if (list) { var items = list.querySelectorAll('li'); publishedScriptsNumber = items.length; } else { console.log('没有找到指定的OL元素'); } })(); displayTotals(dailyInstallsSum, totalInstallsSum); })();