Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Spigot Price Calculator
// ==UserScript==
// @name Spigot Price Calculator
// @namespace http://dustplanet.de
// @version 0.1.2
// @description Calculates the total amount you have earned with your premium plugin.
// @author xGhOsTkiLLeRx
// @match https://www.spigotmc.org/resources/*/buyers
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
let prices = Array.from(document.querySelectorAll('.memberListItem .extra div.muted'));
let price = 0;
// iterate through buyers
for (let _price of prices) {
let text = _price.textContent.trim();
let clean = text.replace( /^\D+/g, '').replace(/ EUR/, '');
price += +clean;
}
price = price.toFixed(2);
let fees = (prices.length * 0.35 + price / 100 * 1.9).toFixed(2);
let total = (price - fees).toFixed(2);
let div = document.querySelector('.innerContent div');
let content = document.createElement('div');
let text = document.createElement('h3');
text.style.fontSize = '16pt';
text.textContent = `Total buyers: ${prices.length}, so far earned: €${price}, PayPal took €${fees}€, total: €${total}€`;
content.appendChild(text);
div.insertBefore(content, div.childNodes[2]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment