Created
September 5, 2019 06:49
-
-
Save LeLocTai/5ec980f1b65c77f517f6eb356a6c3ade to your computer and use it in GitHub Desktop.
For use in Unity Asset Store sale page dev console
This file contains hidden or 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
(async function get() { | |
const publisher_id = 17505; | |
const period = 12; //months | |
function nextMon(current) { | |
let mon = --current[1]; | |
let year = current[0]; | |
if (mon < 1) { | |
year--; | |
mon = 12; | |
} | |
return [year, mon]; | |
} | |
const now = new Date(); | |
const from = [now.getFullYear(), now.getMonth() + 1]; | |
let current = from; | |
let tsv = 'Month Net\n'; | |
for (_ = 0; _ < period; _++) { | |
const res = await fetch( | |
`https://publisher.assetstore.unity3d.com/api/publisher-info/sales/${publisher_id}/${current[0] * 100 + | |
current[1]}.json` | |
); | |
const data = await res.json(); | |
const net = data.result.map(s => parseFloat(s.net.slice(2))).reduce((sum, x) => (sum += x), 0); | |
tsv += `${current[0]}-${current[1]}-01 ${net}\n`; | |
current = nextMon(current); | |
} | |
console.log('Done!'); | |
return tsv; | |
})().then(copy); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: