Created
December 10, 2020 21:43
-
-
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
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
// 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