Skip to content

Instantly share code, notes, and snippets.

@RazerMoon
Created December 10, 2020 21:43
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 RazerMoon/213564cdc406171670094749b599b03e to your computer and use it in GitHub Desktop.
Save RazerMoon/213564cdc406171670094749b599b03e to your computer and use it in GitHub Desktop.
Uses a very simple calculation to determine a Patreon user's/campaign's earnings and logs it to console
// I personally use this as a snippet and run it after the patreon page loads
// Note: There is a severe lack of error checking present in this, but it works for most pages that hide the earnings (that I have tried)
let {data, included} = patreon.bootstrap.campaign;
let {patron_count} = data.attributes;
let rewards = included.filter(({type, id, attributes}) => {return (type && type === "reward" && id > 0) ? true : false;}).map(({attributes}) => attributes.amount_cents / 100);
if (patron_count) {
//console.log(patron_count);
//console.dir(rewards);
console.log(`This creator is making between ${rewards[0] * patron_count} and ${rewards[rewards.length - 1] * patron_count}`);
} else {
console.log("patron_count hidden");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment