Greasy Fork

Greasy Fork is available in English.

GreasyFork用户主页显示该用户所有脚本的今日总安装次数和迄今总安装次数

在GreasyFork用户主页显示该用户所有脚本的今日总安装次数和迄今总安装次数。

当前为 2023-12-19 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name           GreasyFork用户主页显示该用户所有脚本的今日总安装次数和迄今总安装次数
// @namespace      http://tampermonkey.net/
// @version        0.2
// @description    在GreasyFork用户主页显示该用户所有脚本的今日总安装次数和迄今总安装次数。
// @author         aspen138
// @match          http://greasyfork.icu/*/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 사용자 홈페이지는 해당 사용자의 모든 스크립트에 대한 당일 총 설치 횟수와 지금까지의 총 설치 횟수를 표시합니다。
// ==/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', `
            <div>${dailyInstallsText}</div>
            <div>${totalInstallsText}</div>
        `);
		}
	};
	const dailyInstallsSum = sumInstalls('dd.script-list-daily-installs > span');
	const totalInstallsSum = sumInstalls('dd.script-list-total-installs > span');

	displayTotals(dailyInstallsSum, totalInstallsSum);
})();