Last active
May 10, 2024 15:02
-
-
Save stevelacey/c15234fa7080a5eabe800e46bae69f40 to your computer and use it in GitHub Desktop.
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
const widget = new ListWidget() | |
widget.backgroundColor = Color.black() | |
const amount = (number) => '$' + new Intl.NumberFormat().format(Math.round(number)) | |
const text = (text, fontSize) => { | |
const t = widget.addText(text) | |
t.font = new Font('Avenir-Heavy', fontSize) | |
t.textColor = Color.white() | |
} | |
const alias = { | |
'Freetrade': 'FT', | |
'TransferWise': 'TW', | |
} | |
data.balances.slice(0, 6).forEach(balance => { | |
balance.name = alias[balance.name] || balance.name | |
text(`${amount(balance.total)} ${balance.name}`, 12) | |
}) | |
text(`${amount(data.total)} 🔥️`, 16) | |
Script.setWidget(widget) | |
Script.complete() |
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
const widget = new ListWidget() | |
widget.backgroundColor = Color.black() | |
const amount = (number) => '$' + new Intl.NumberFormat().format(Math.round(number)) | |
const text = (text, fontSize) => { | |
const t = widget.addText(text) | |
t.font = new Font('Avenir-Heavy', fontSize) | |
t.textColor = Color.white() | |
} | |
data.positions.sort((a, b) => b.total - a.total).slice(0, 18).forEach(position => { | |
text(`${amount(position.total)} ${position.name} (${position.symbol})`, 12) | |
}) | |
Script.setWidget(widget) | |
Script.complete() |
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
const request = new Request('https://path/to/some/json') | |
const data = await request.loadJSON() | |
const gist = new Request(`${args.widgetParameter}?v=${Math.round(new Date().getTime() / 1000)}`) | |
const script = await gist.loadString() | |
eval(script) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment