Skip to content

Instantly share code, notes, and snippets.

@timbru31
Last active January 6, 2017 19:52

Revisions

  1. timbru31 revised this gist Jan 6, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions spigot_price_calculator.user.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    // ==UserScript==
    // @name Spigot Price Calculator
    // @namespace http://dustplanet.de
    // @version 0.1.1
    // @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
    @@ -28,6 +28,6 @@ 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}€`;
    text.textContent = `Total buyers: ${prices.length}, so far earned: ${price}, PayPal took ${fees}€, total: ${total}€`;
    content.appendChild(text);
    div.insertBefore(content, div.childNodes[2]);
  2. timbru31 renamed this gist Oct 9, 2016. 1 changed file with 0 additions and 0 deletions.
  3. timbru31 revised this gist Dec 12, 2015. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions spigot_price_calculator.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    // ==UserScript==
    // @name Spigot Price Calculator
    // @namespace http://dustplanet.de
    // @version 0.1
    // @version 0.1.1
    // @description Calculates the total amount you have earned with your premium plugin.
    // @author xGhOsTkiLLeRx
    // @match https://www.spigotmc.org/resources/*/buyers
    @@ -20,12 +20,14 @@ for (let _price of prices) {
    let clean = text.replace( /^\D+/g, '').replace(/ EUR/, '');
    price += +clean;
    }
    price = Math.round(price * 100) / 100;
    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} EUR`;
    text.textContent = `Total buyers: ${prices.length}, so far earned: ${price}€, PayPal took ${fees}€, total: ${total}`;
    content.appendChild(text);
    div.insertBefore(content, div.childNodes[2]);
    div.insertBefore(content, div.childNodes[2]);
  4. timbru31 created this gist Dec 12, 2015.
    31 changes: 31 additions & 0 deletions spigot_price_calculator.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    // ==UserScript==
    // @name Spigot Price Calculator
    // @namespace http://dustplanet.de
    // @version 0.1
    // @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 = Math.round(price * 100) / 100;

    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} EUR`;
    content.appendChild(text);
    div.insertBefore(content, div.childNodes[2]);