Last active
January 6, 2017 19:52
-
-
Save timbru31/f0c2408b1b31ef24e83c to your computer and use it in GitHub Desktop.
Spigot Price Calculator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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