Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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.
// ==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
You can’t perform that action at this time.