Skip to content

Instantly share code, notes, and snippets.

@ttt50966
Created January 28, 2022 09:37
Show Gist options
  • Save ttt50966/e33f506552bce07618918cc525d1b0d3 to your computer and use it in GitHub Desktop.
Save ttt50966/e33f506552bce07618918cc525d1b0d3 to your computer and use it in GitHub Desktop.
//Author: Kuàn-ka
//This is a "LikeCoin" script for Scriptable
//Please dowonload the app below first
//https://apps.apple.com/tw/app/scriptable/id1405459188
digits = 3
likecoin_ntd_url = "https://api.coingecko.com/api/v3/simple/price?ids=likecoin&vs_currencies=twd"
let r = new Request(likecoin_ntd_url)
let ntd_json = await r.loadJSON()
likecoin_hkd_url = "https://api.coingecko.com/api/v3/simple/price?ids=likecoin&vs_currencies=hkd"
let r1 = new Request(likecoin_hkd_url)
let hkd_json = await r1.loadJSON()
likecoin_ntd = ntd_json["likecoin"]["twd"].toFixed(3)
likecoin_hkd = hkd_json["likecoin"]["hkd"].toFixed(3)
likecoin_usd_url = "https://api.coingecko.com/api/v3/simple/price?ids=likecoin&vs_currencies=usd"
let r2 = new Request(likecoin_usd_url)
let likecoin_usd_json = await r2.loadJSON()
likecoin_usd = likecoin_usd_json["likecoin"]["usd"].toFixed(3)
const width=125
const h=7
const w = new ListWidget()
REFRESH_INTERVAL = 0.5 //mins
w.backgroundColor=new Color("#222222")
var refreshDate = Date.now() + 1000*60*REFRESH_INTERVAL
w.refreshAfterDate = new Date(refreshDate)
w.addSpacer(3)
let provider = w.addText("1 LikeCoin")
provider.font = Font.mediumSystemFont(24)
provider.textColor = new Color("#2D6563")
w.addSpacer(7)
let provider2 = w.addText(Number(likecoin_ntd).toFixed(3)+" NTD")
provider2.font = Font.mediumSystemFont(22)
provider2.textColor = new Color("#BBA472")
let provider3 = w.addText(Number(likecoin_hkd).toFixed(3)+" HKD")
provider3.font = Font.mediumSystemFont(22)
provider3.textColor = new Color("#BBA472")
let provider4 = w.addText(Number(likecoin_usd).toFixed(3)+" USD")
provider4.font = Font.mediumSystemFont(22)
provider4.textColor = new Color("#BBA472")
w.addSpacer(14)
Script.setWidget(w)
Script.complete()
w.presentSmall()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment