Last active
December 14, 2017 17:59
-
-
Save foosel/3b6f96bb99257edd2fa145225411d25f to your computer and use it in GitHub Desktop.
Small user script to be used with something like TamperMonkey that will add a tooltip to the "x receives y per week from z patrons" that provides the amount per month. Currently only works with the english locale of liberapay.
This file contains 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 Liberapay donations per month | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Hovering over the "user receives ... per week from ... patrons" will now show the received amount per month. Currently only works for the english version since it matches the header line via the contained text - couldn't find better attributes for that. | |
// @author Gina Häußge <osd@foosel.net> | |
// @match https://liberapay.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var element = $(".profile-header-bar div.flex-col:contains('per week from')"); | |
var amount = element.find("b")[0]; | |
var perWeekText = amount.innerText; | |
var perWeek = Number(perWeekText.replace(/[^0-9\.-]+/g, "")); | |
var perMonth = perWeek * 52 / 12; | |
var perMonthText = String(Math.round(perMonth * 100) / 100); | |
if (perWeekText[0] === "€") { | |
perMonthText = "€" + perMonthText; | |
} else if (perWeekText[0] === "$") { | |
perMonthText = "$" + perMonthText; | |
} | |
element[0].title = perMonthText + " per month"; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment