Shows a user's total downloads.
当前为
// ==UserScript==
// @name Greasy Fork Total Downloads
// @namespace -
// @version 1.0.0
// @description Shows a user's total downloads.
// @author NotYou
// @include *://greasyfork.org/*/users/*
// @include *://sleazyfork.org/*/users/*
// @match *://greasyfork.org/*/users/*
// @match *://sleazyfork.org/*/users/*
// @license GPL-3.0
// @run-at document-body
// @grant none
// ==/UserScript==
window.addEventListener('DOMContentLoaded', () => {
let totalInstalls = 0
let totalDailyInstalls = 0
let userLocale = document.querySelector('#language-selector-locale').value || 'en-US'
document.querySelectorAll('#user-script-list > li dd.script-list-total-installs span').forEach(e => {
totalInstalls += +e.textContent.replace(/\D/g, '')
})
document.querySelectorAll('#user-script-list > li dd.script-list-daily-installs span').forEach(e => {
totalDailyInstalls += +e.textContent.replace(/\D/g, '')
})
let totalInstallsConverted = totalInstalls.toLocaleString(userLocale)
let totalDailyInstallsConverted = totalDailyInstalls.toLocaleString(userLocale)
document.querySelector('div.sidebarred-main-content h3:first-child').insertAdjacentHTML('beforeend',
createInstallsStat(totalInstallsConverted, 'rgb(123, 23, 23)') +
createInstallsStat(totalDailyInstallsConverted, 'rgb(185, 32, 32)')
)
function createInstallsStat(value, color) {
return `
<span style="font-size: 15px;border-radius: 3px;background: rgb(45, 45, 45);color: rgb(255, 255, 255);margin: 0px 4px;padding: 0 4px;outline: 2px solid ${color};">
<span style="width: 8px;height: 8px;display: inline-flex;margin-bottom: 1px;margin-left: 4px;border-radius: 50%;background: ${color};"></span>
${value} Installs
</span>`
}
})