Skip to content

Instantly share code, notes, and snippets.

@timbru31
Last active January 6, 2017 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timbru31/f0c2408b1b31ef24e83c to your computer and use it in GitHub Desktop.
Save timbru31/f0c2408b1b31ef24e83c to your computer and use it in GitHub Desktop.
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