Skip to content

Instantly share code, notes, and snippets.

@LeLocTai
Created September 5, 2019 06:49
Show Gist options
  • Save LeLocTai/5ec980f1b65c77f517f6eb356a6c3ade to your computer and use it in GitHub Desktop.
Save LeLocTai/5ec980f1b65c77f517f6eb356a6c3ade to your computer and use it in GitHub Desktop.
For use in Unity Asset Store sale page dev console
(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);
@LeLocTai
Copy link
Author

LeLocTai commented Sep 5, 2019

Usage:

  1. Edit the 2 and 3 line to your publisher id and desired period. Save the script somewhere for later use.
  2. Goto your sale page.
  3. Open dev tool. F12 on chrome, google for your browser.
  4. Paste the script to the console tab, Enter.
  5. Wait till it say done. Result auto copied, just paste to excel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment